Skip to content

Conversation

walkie
Copy link
Contributor

@walkie walkie commented Dec 8, 2021

This adds a new feature thread_safe to the rust backend. When enabled, the generated state machine will implement the Send and Sync traits, as long as all declared domain variables also implement these traits.

By far the biggest impact of this feature is on the runtime interface, which has been split into two variants:

  • frame_runtime::sync, which is implemented by machines compiled with runtime_support=true and thread_safe=true

  • frame_runtime::unsync, which is implemented by machines compiled with runtime_support=true and thread_safe=false

The treatment of environments in the sync runtime interface is much less efficient than in the unsync variant, and the sync variant also requires that all domain variables implement Clone. For most applications, these issues probably won't be a problem. They're both issues that could probably be fixed with some refactoring effort, but I've put a ton of bandwidth into this already, so I'm leaving it as is (which is a decent interface with as little redundancy as I could manage between the two variants) until/unless they become an issue.

The sync'd version still needs some testing and the code generator hasn't been updated yet, so the full test suite is broken. However, the current runtime system tests are working again + a few extras.
The treatment of environments for this variant is really inefficient, but it works and I've gotta get on with my life... :-P
The sync variant of the codegen is still untested, but all unsync tests pass again.
Also adds the multi-threaded test to the unsync variant.
@walkie walkie merged commit 7f4fdd1 into main Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant