Expose OSThreadID and assorted functions from Haskell
Currently given two ThreadId
s, there is no way to tell without FFI if they are running on the same OS thread. There is not even a way to ask what OS thread we are currently on: something like myThreadId
except myOsThreadId
.
Currently to remedy this, the user has to effectively copy and paste parts of the internal rts files and use something like .hsc
with CPP to get at this information. This is not really portable on the user side and requires nasty gutting.
In the RTS the function we are interested in is at least osThreadId
: with this function we can inspect current OSThreadId
and communicate it out through an MVar
or otherwise.
So this is a feature request for an abstract type OSThreadId
with instances of at least Eq, Show
and a function myOsThreadId :: IO OSThreadId
.
Nice to have would be osThreadId :: ThreadID -> IO OSThreadId
but not critical. If there is room for optimisation in GHC, functions like sameOsThread :: ThreadId -> ThreadId -> IO Bool
would also be nice but again not critical.
Not sure what to set in ticket meta-data so please change as appropriate.