Re: [Haskell-cafe] Getting the 'ThreadId' of the calling thread

2013-08-02 Thread Nikita Karetnikov
 Other actions such as withLinksDo and forkLinkIO' insert stuff into
 threadMap. It can be non-mepty.

Thanks (again), Albert.  Later, I found this comment above the
'withLinksDo' function: It is an error to call this function outside
the main thread, or to call any other functions in this module outside
this function.

Here's the simplest example that doesn't return the exception:

instance Show ThreadId where
  show (Tid u) = show . hashUnique $ u

main = do
  tid  - C.myThreadId
  tid' - fmap Tid newUnique
  modifyMVar_ threadMap $ \tm -
return $ tm { state = M.singleton tid
  $ ThreadState { ident = tid'
, signal= defaultSignal tid
, links = S.empty
, monitors  = M.empty
, ownedMons = S.empty } }
  myThreadId


pgpDiseWy6nvJ.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Getting the 'ThreadId' of the calling thread

2013-08-01 Thread Albert Y. C. Lai

On 13-07-29 08:35 AM, Nikita Karetnikov wrote:

I feel that a 'myThreadId' action, which is defined in this module [1],
is useless, but I'm not sure.  I think it will always return the
Map.find: element not in the map exception because a 'threadMap'
contains an empty 'ThreadMap'.

Is it right, or am I missing something?


Other actions such as withLinksDo and forkLinkIO' insert stuff into 
threadMap. It can be non-mepty.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Getting the 'ThreadId' of the calling thread

2013-07-29 Thread Nikita Karetnikov
(I'm trying to update a package that was written with GHC 6.10.4 in
mind.)

I feel that a 'myThreadId' action, which is defined in this module [1],
is useless, but I'm not sure.  I think it will always return the
Map.find: element not in the map exception because a 'threadMap'
contains an empty 'ThreadMap'.

Is it right, or am I missing something?

[1] 
https://gitweb.torproject.org/tordnsel.git/blob/HEAD:/src/TorDNSEL/Control/Concurrent/Link/Internals.hs


pgpDV3Pyy5Laq.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe