bacon-rajan-cc
bacon-rajan-cc copied to clipboard
How to use Cc<T> with multithreading?
I want to implement a multi-threaded interpreter with Cc<T>
.
Does Mutex<Cc<T>>
work?
Yes, Mutex<Cc<T>> should work.
Actually, I might be wrong. There's a thread local buffer and it's pretty believable that things could break if you share Cc's across threads.
We should create a Acc
or something similar that can be sent or shared between threads. It seems like at the start of collect_cycle
we can run a trace()
over the nodes and lock all the ones that are going to take part in collect_cycles
, then use trace()
again to unlock all those nodes at the end of collect_cycles()
. So that multiple collect_cycles
from different threads can execute simultaneously if they are talking to independent nodes.
I put up a prototype of what this could look like at https://github.com/jrmuizel/cc-mt