Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Callback a
- data OnBlocked
- releaseCallback :: Callback a -> IO ()
- asyncCallback :: IO () -> IO (Callback (IO ()))
- asyncCallback1 :: (JSVal -> IO ()) -> IO (Callback (JSVal -> IO ()))
- asyncCallback2 :: (JSVal -> JSVal -> IO ()) -> IO (Callback (JSVal -> JSVal -> IO ()))
- asyncCallback3 :: (JSVal -> JSVal -> JSVal -> IO ()) -> IO (Callback (JSVal -> JSVal -> JSVal -> IO ()))
- syncCallback :: OnBlocked -> IO () -> IO (Callback (IO ()))
- syncCallback1 :: OnBlocked -> (JSVal -> IO ()) -> IO (Callback (JSVal -> IO ()))
- syncCallback2 :: OnBlocked -> (JSVal -> JSVal -> IO ()) -> IO (Callback (JSVal -> JSVal -> IO ()))
- syncCallback3 :: OnBlocked -> (JSVal -> JSVal -> JSVal -> IO ()) -> IO (Callback (JSVal -> JSVal -> JSVal -> IO ()))
- syncCallback' :: IO JSVal -> IO (Callback (IO JSVal))
- syncCallback1' :: (JSVal -> IO JSVal) -> IO (Callback (JSVal -> IO JSVal))
- syncCallback2' :: (JSVal -> JSVal -> IO JSVal) -> IO (Callback (JSVal -> JSVal -> IO JSVal))
- syncCallback3' :: (JSVal -> JSVal -> JSVal -> IO JSVal) -> IO (Callback (JSVal -> JSVal -> JSVal -> IO JSVal))
Documentation
The runtime tries to run synchronous threads to completion. Sometimes it's
not possible to continue running a thread, for example when the thread
tries to take an empty MVar
. The runtime can then either throw a
WouldBlockException
, aborting the blocking action, or continue the
thread asynchronously.
ContinueAsync | continue the thread asynchronously if blocked |
ThrowWouldBlock | throw |
releaseCallback :: Callback a -> IO () Source #
When you create a callback, the Haskell runtime stores a reference to the exported IO action or function. This means that all data referenced by the exported value stays in memory, even if nothing outside the Haskell runtime holds a reference to to callback.
Use releaseCallback
to free the reference. Subsequent calls from JavaScript
to the callback will result in an exception.
asynchronous callbacks
Make a callback (JavaScript function) that runs the supplied IO action in an asynchronous thread when called.
Call releaseCallback
when done with the callback, freeing data referenced
by the IO action.
synchronous callbacks
:: OnBlocked | what to do when the thread blocks |
-> IO () | the Haskell action |
-> IO (Callback (IO ())) | the callback |
Make a callback (JavaScript function) that runs the supplied IO action in a synchronous thread when called.
Call releaseCallback
when done with the callback, freeing memory referenced
by the IO action.
:: OnBlocked | what to do when the thread blocks |
-> (JSVal -> IO ()) | the Haskell function |
-> IO (Callback (JSVal -> IO ())) | the callback |
Make a callback (JavaScript function) that runs the supplied IO function in a synchronous thread when called. The callback takes one argument that it passes as a JSVal value to the Haskell function.
Call releaseCallback
when done with the callback, freeing data referenced
by the function.
:: OnBlocked | what to do when the thread blocks |
-> (JSVal -> JSVal -> IO ()) | the Haskell function |
-> IO (Callback (JSVal -> JSVal -> IO ())) | the callback |
Make a callback (JavaScript function) that runs the supplied IO function in a synchronous thread when called. The callback takes two arguments that it passes as JSVal values to the Haskell function.
Call releaseCallback
when done with the callback, freeing data referenced
by the function.
:: OnBlocked | what to do when the thread blocks |
-> (JSVal -> JSVal -> JSVal -> IO ()) | the Haskell function |
-> IO (Callback (JSVal -> JSVal -> JSVal -> IO ())) | the callback |
Make a callback (JavaScript function) that runs the supplied IO function in a synchronous thread when called. The callback takes three arguments that it passes as JSVal values to the Haskell function.
Call releaseCallback
when done with the callback, freeing data referenced
by the function.
synchronous callbacks that return a value
syncCallback' :: IO JSVal -> IO (Callback (IO JSVal)) Source #
Make a callback (JavaScript function) that runs the supplied IO action in a synchronous thread when called.
Call releaseCallback
when done with the callback, freeing memory referenced
by the IO action.