Add thread_safe feature to generate Send+Sync compatible state machines #68
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a new feature
thread_safe
to the rust backend. When enabled, the generated state machine will implement theSend
andSync
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 withruntime_support=true
andthread_safe=true
frame_runtime::unsync
, which is implemented by machines compiled withruntime_support=true
andthread_safe=false
The treatment of environments in the
sync
runtime interface is much less efficient than in theunsync
variant, and thesync
variant also requires that all domain variables implementClone
. 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.