In the short term, you can do what I do, use a combination of IORef and
unsafePerformIO to store the ThreadId into a "global variable". I try
not to use this too much though, since it does break down the purely
functional aspect of Haskell.

George Russell wrote:
> 
> Yes, it's me again.  Could there be an action in the Concurrent library
> which returns the ThreadId for the current thread?  Argument for:
> (1) this seems easy to implement.
> (2) it can't be simulated using the other functions.  (At least, not so far
>     as I can see.)
> (3) if you want to write a lot of code that involves doing things to this
>     thread (which seems rather likely to me), or identifying this thread in
>     a unique way, you have to (a) get the ThreadID from the parent thread into
>     this one (using an MVar say, ugh!) and then (b) haul it around as an
>     argument all the time (ugh ugh!).
> I have purely selfish reasons for making this request; namely I have
> a chunk of Haskell to maintain which makes heavy use of such a function, but
> implements it via a _ccall which pokes around with GHC's internals.
> 
> Sorry to keep on about Concurrent, and if this is the wrong mailing list
> for talking about the Hugs/GHC extensions do let me know.
> 
> Many thanks
> 
> George Russell

Reply via email to