I still remember my own troubles when learning Nim, so if I may ... I'm under 
the impression that your problems are more of the (partly Nim specific) 
conceptional kind.

Nim offers _both_ the classical threads and thread pools. Pools should be used 
for relatively simple "quick worker jobs". Things like handling a server 
connection/session where the main loop just hands the connections to workers. 
Classical threads on the other hand should be used when more complicated and 
longer lived jobs are to be spread over multiple cores. The trade off is more 
or less one of comfort vs control/features. Pools are comfortable but offer 
less (easy) detail control and features (like easily passing objects around). 
Threads on the other hand are less comfortable but offer full control and 
features.

Another point is that thread creation is relatively expensive so reusing them 
(as in a pool) makes sense and offers advantages for quick worker jobs while 
classical threads are better suited for long lived and complex jobs.

> Aiesha_Nazarothi > > Hm. But then... Is there, like, any way to supply thread 
> with modifiable objects, like... well, everywhere else ?

There is a reason for Rusts complexity (and I'll not even talk about Pony). 
Modifiable objects are one of the major sources for bugs and unsafe code. Let's 
look at the major approaches to understand the field better:

  * "Who cares? All power to the developers!" (C, C++, ...). Advantage: 
Freedom, incl. the freedom to shoot ones leg. Disadvantage: Same.
  * "Control. Tight control" (Rust, Pony, Ada, ...). Advantage: way more safe 
code. Disadvantage: Difficult to grasp and to use properly. Cumbersome.
  * Nim style (GC + ref/ptr). Advantage: way safer code plus quite easy to use. 
Disadvantage: GC (I'll stay away from "religious" remarks of which there is 
plenty) and some (mild) amount of complexity (like "How to pass modifiable 
stuff around?"). Plus some sharp corners and lacking ease of use and elegance - 
but that is due to Nim still not being 1.0 and (I strongly presume) will 
change. From everything I've seen so far from @Araq I can't but be sure that 
Nim will take off the sharp edges and add ease of use and elegance.



Finally, wrt to your concrete case we should understand it better and know more 
to find the right approach. Are your threads long lived complex beasts or more 
of the quick worker kind? The modifiable memory you need to pass around, what's 
its structure (e.g. plain chunks, objects, records/structs, ...?) and how 
frequently do you need to pass it around? etc.

Reply via email to