Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SyncFunction #149

Merged
merged 1 commit into from
Oct 11, 2020
Merged

Add support for SyncFunction #149

merged 1 commit into from
Oct 11, 2020

Conversation

udoprog
Copy link
Collaborator

@udoprog udoprog commented Oct 11, 2020

Regular Functions are not thread-safe, since they might contain a closure which has captured some of the runtime state of Rune.

This adds support for SyncFunction, which takes ownership of the runtime state that it's captured and converts it into a ConstValue. ConstValues are an owned variation of Value which does not perform the same ownership work as Value.

This currently does have the effect of moving any captured values, which really should be implemented in two separate ways. And the concepts map quite nicely to rust's move operator.

let value = /* .. */;

// This should clone the value if converted to a sync function.
let a = || {
    dbg(value);
}

let value = /* .. */;

// This should move value.
let b = move || {
    dbg(value);
}

@udoprog udoprog added the enhancement New feature or request label Oct 11, 2020
@udoprog udoprog merged commit c187a36 into master Oct 11, 2020
@udoprog udoprog deleted the sync-function branch October 11, 2020 20:24
@udoprog udoprog added the changelog Issue has been added to the changelog label Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog Issue has been added to the changelog enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant