Proposal: Add rtsIsThreaded to base

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Tue Apr 26 13:26:47 UTC 2016


On 26 April 2016 at 22:36, Merijn Verstraaten <merijn at inconsistent.nl> wrote:
> 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).

I may very well be wrong with this, but off the top of my head if the
library is installed globally (either manually, non-sandboxed
cabal-install or using stack in some fashion), then I don't think
whether a particular _executable_ is compiled with a
multi-/single-threaded runtime system would affect the value from a
constant that's already been compiled (unless INLINE is used to
prevent it being pre-computed).

>
> Cheers,
> Merijn
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>



-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com


More information about the Libraries mailing list