summaryrefslogtreecommitdiff
path: root/libraries/base/Control/Concurrent.hs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/base/Control/Concurrent.hs')
-rw-r--r--libraries/base/Control/Concurrent.hs35
1 files changed, 33 insertions, 2 deletions
diff --git a/libraries/base/Control/Concurrent.hs b/libraries/base/Control/Concurrent.hs
index 1bf020b8a9..87ddc9584a 100644
--- a/libraries/base/Control/Concurrent.hs
+++ b/libraries/base/Control/Concurrent.hs
@@ -105,17 +105,25 @@ module Control.Concurrent (
) where
+-- JavaScript platform doesn't support bound threads
+#if !defined(js_HOST_ARCH)
+#define SUPPORT_BOUND_THREADS
+#endif
+
import Control.Exception.Base as Exception
import GHC.Conc hiding (threadWaitRead, threadWaitWrite,
threadWaitReadSTM, threadWaitWriteSTM)
+
+#if defined(SUPPORT_BOUND_THREADS)
import GHC.IO ( unsafeUnmask, catchException )
import GHC.IORef ( newIORef, readIORef, writeIORef )
import GHC.Base
-
-import System.Posix.Types ( Fd )
import Foreign.StablePtr
import Foreign.C.Types
+#endif
+
+import System.Posix.Types ( Fd )
#if defined(mingw32_HOST_OS)
import Foreign.C
@@ -250,6 +258,27 @@ waiting for the results in the main thread.
-}
+#if !defined(SUPPORT_BOUND_THREADS)
+forkOS :: IO () -> IO ThreadId
+forkOS _ = error "forkOS not supported on this architecture"
+
+forkOSWithUnmask :: ((forall a . IO a -> IO a) -> IO ()) -> IO ThreadId
+forkOSWithUnmask _ = error "forkOS not supported on this architecture"
+
+isCurrentThreadBound :: IO Bool
+isCurrentThreadBound = pure False
+
+runInBoundThread :: IO a -> IO a
+runInBoundThread action = action
+
+runInUnboundThread :: IO a -> IO a
+runInUnboundThread action = action
+
+rtsSupportsBoundThreads :: Bool
+rtsSupportsBoundThreads = False
+#else
+
+
-- | 'True' if bound threads are supported.
-- If @rtsSupportsBoundThreads@ is 'False', 'isCurrentThreadBound'
-- will always return 'False' and both 'forkOS' and 'runInBoundThread' will
@@ -390,6 +419,8 @@ runInUnboundThread action = do
unsafeResult :: Either SomeException a -> IO a
unsafeResult = either Exception.throwIO return
+#endif
+
-- ---------------------------------------------------------------------------
-- threadWaitRead/threadWaitWrite