[M3devel] Per thread data

Rodney M. Bates rodney_bates at lcwb.coop
Tue Sep 14 17:17:47 CEST 2010


Another way:

Put your thread-specific data in local variables of the topmost procedure of your
thread, i.e., the procedure that you override Thread.Closure.apply with.
Then you can access it in either of two ways, or a mixture:

1) Nest other procedures inside the topmost procedure and use nonlocal references
    to the thread-specific data.
2) Pass it (probably by reference) to/thru any non-nested procedures you really must have.

Any code you don't have control over would not have any way of knowing about your
thread-specific data, except if you passed it as parameter(s).

Darko wrote:
> I need to have certain data structures allocated on a per thread basis. Right now I'm thinking of using the thread id from ThreadF.MyId() to index a list. Is there a better, more portable way of allocating on a per-thread basis?
> 
> Cheers,
> Darko.
> 
> 



More information about the M3devel mailing list