You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dyon uses the go keyword to create a concurrent coroutine, similar to Go, but with the difference that Dyon uses the return value.
Example:
fnfoo() -> str{sleep(1.0)return"done"}fnmain(){
foo_thread := go foo()sleep(0.5)
val := join(thread: foo_thread)ifis_err(val){// An error happened when running the threadprintln(unwrap_err(val))}else{// Prints `done`println(unwrap(val))}}
To provide thread safety:
Arguments are evaluated on the same stack
Arguments are deep cloned over to the new run-time's stack
Creating a fake AST call using expression references to the deep cloned arguments
The thread evaluates the fake AST call on a new thread
The remaining value on the new stack is the result
The new result is deep cloned
Rules:
go foo() requires -> on the function foo
go foo(a, b) must have no lifetimes on arguments of foo, because the evaluated arguments are ordered by the call and do not necessarily have the same order in the lifetime check
The text was updated successfully, but these errors were encountered:
Dyon uses the
go
keyword to create a concurrent coroutine, similar to Go, but with the difference that Dyon uses the return value.Example:
To provide thread safety:
Rules:
go foo()
requires->
on the functionfoo
go foo(a, b)
must have no lifetimes on arguments offoo
, because the evaluated arguments are ordered by the call and do not necessarily have the same order in the lifetime checkThe text was updated successfully, but these errors were encountered: