-
Notifications
You must be signed in to change notification settings - Fork 5
Concurrency design study
Reini Urban edited this page Sep 17, 2013
·
14 revisions
Since potion is message-passing based it would be pretty easy to support accessing variables and calling functions in other threads just by adding a MOP layer to check for the tid in send (aka 'remoting').
Some languages require compile-time typing for foreign objects to create efficient remoting.
callcc/yield does not work across threads yet.
We want to support fast lightweight coroutines (callcc/yield) in the same thread (esp. for IO), as well as parallel processing via OS threads for CPU-heavy code.
There are essentially 2 opposing philosophies for MTP.
for calls, control flow:
- non-blocking calls and updates (fork/join) with explicit waits,
async/wait(fast, but deadlocking) - blocking calls in
recvand explicitselectandyield(Go - safe)
for data:
- shared-memory (jvm, .net, ...), vs
- message-passing via channels, either by reference (mailbox - fast) or by copying (Go - safe).
And explicit parallelization by something like pfor, pwhile, pmap, pgrep,
- with waiting per loop iteration (perl6
hyper- sorted results) or - waiting at the end (perl6
race- unsorted, but faster).
async could change the type of upvals automatically
- primitives (word-size) allow atomic CAS supported updates. no need to lock or proxy.
- objects need to be locked, when being updated, or
- referenced via proxies in threads and updated only by async calls of the owner thread.
- Does
asyncneeds to create copies of called closures or just copies of locals (TLS). - Forbid untyped upvals (access to lexical remotes), or proxy them automatically? (my $a :shared;)