@alexeypetrushin Sorry I missed reading your postscriptum:

> P.S. There's also a way to use {.threadvar.} and keep separate copy for each 
> thread. But it defeats the whole point of having multi threaded server that 
> could optimise memory by sharing some common data between threads.

Yes, you're right that it's sub-optimal, and I don't believe there's a way to 
do this safely with refs today in the general sense, without having to deal 
with locking/consistency mechanisms and taking into consideration specific 
access patterns.

If I understand correctly, this may become possible through the use of view 
types. <https://nim-lang.org/docs/manual_experimental.html#view-types>

In the mean time, there's lots of way to share things across threads 
(`sharedtable`, `smartptrs` module from fusion, etc.) There's just no great 
solution for refs, AFAIK. 

Reply via email to