Proposal: Add rtsIsThreaded to base

Merijn Verstraaten merijn at inconsistent.nl
Tue Apr 26 12:36:53 UTC 2016


I would propose adding a Bool value to base that indicates whether the code was compiled/linked with the threaded or single threaded runtime system. A library might want to implement certain functionality differently depending on whether the threaded runtime system is used (i.e. avoid blocking C FFI calls in single-threaded).

There is currently no good way to do this. StackExchange currently suggests using "Control.Concurrent.rtsSupportsBoundThreads" for this, which is defined as:

HsBool rtsSupportsBoundThreads(void) {
#if defined(THREADED_RTS)

  return HS_BOOL_TRUE;
#else
  return HS_BOOL_FALSE;
#endif
}

But it seems undesirable to conflate support for bound threads and use of the threaded runtime system? Especially since this would be a trivial addition to Control.Concurrent (i.e. simply an ifdef'ed True/False constant).

Cheers,
Merijn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160426/2337a0cb/attachment.sig>


More information about the Libraries mailing list