
Daneel Yaitskov
Hi,
There are 2 questions:
1. How to decipher myThreadId implementation in STG? What is the principle behind STG version? Is it matching first field from TSO by type? "id" is not mentioned anyhow and there is no offset to id field. The whole TSO struct is just mentioned.
See the Haddocks for GHC.Conc.Sync.ThreadId. In short, ThreadId# (which is what the myThreadId# primop returns) is an opaque thread identifier which is represented by a pointer to a TSO. The Show instance for ThreadId prints the `id` field of the TSO. However, we don't directly expose the `id` field to the user; you merely get Eq and Ord instances. Admittedly, this may be a problem for users wanting to use, e.g., a HashMap keyed on ThreadId. Perhaps we could expose the GHC.Conc.Sync.getThreadId to the user. However, using this correctly would take great care. Cheers, - Ben