[M3devel] Per thread data

Mika Nystrom mika at async.async.caltech.edu
Tue Sep 14 15:50:02 CEST 2010


If you have control over all the code you can (probably?) always do that,
perhaps at the cost of some extra code.  But there are times---such as when
writing an interpreter that interfaces with "any" Modula-3 code---that you
may want to have thread-private data accessible without necessarily being
able to access the thread closure.  In these cases, you don't know how
many threads you have but yet want to have "global" variables.  It would
be really nice to have some interface for doing this without going all the
way through pthreads primitives (or something equivalent)...

     Mika

Tony Hosking writes:
>Why not just allocate in the heap and hold a reference in the thread =
>closure?
>
>On 14 Sep 2010, at 00:14, 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?
>>=20
>> Cheers,
>> Darko.
>>=20



More information about the M3devel mailing list