I'd second `threading/smartptrs` if you need shared mutable data. `SharedPtr` 
uses an atomic reference count which is equivalent with Rust's `Arc<T>` type. 
Though `SharedPtr` like Rust's `Arc<T>` _doesn 't_ provide for locking the 
data. Though you should be able to pass `SharedPtr` via a channel. It should 
just [increment the ref 
count](https://github.com/nim-lang/threading/blob/49562fa0d393e765823b2ea96ca14fbb9889a566/threading/smartptrs.nim#L90).

Note too that `SharedPtr` requires your data to be `isolate` compatible. If the 
compiler can't verify the data is isolated you may need to copy the data once 
on initialization. You can use 
[unsafeIsolate](https://nim-lang.org/docs/isolation.html#unsafeIsolate%2CsinkT) 
if you have a big blog of data that can't be copied and which doesn't make 
`isolate()` happy.

@mratsim's work pools are much nicer if you can refactor the problem into a 
map-reduce style parallelism. 

Reply via email to