Skip to content
Snippets Groups Projects
Commit 4adffe35 authored by Kamil's avatar Kamil
Browse files

Clarify interruptible FFI wrt masking state

parent 274e21f0
No related tags found
No related merge requests found
Pipeline #26660 passed with warnings with stages
in 6 hours, 14 minutes, and 30 seconds
......@@ -315,9 +315,10 @@ be annotated with ``interruptible`` instead of ``safe`` or ``unsafe``: ::
"sleep" sleepBlock :: CUint -> IO CUint
``interruptible`` behaves exactly as ``safe``, except that when a
``throwTo`` is directed at a thread in an interruptible foreign call, an
OS-specific mechanism will be used to attempt to cause the foreign call
to return:
``throwTo`` is directed at a thread in an interruptible foreign call,
irrespective of the masking state, the exception is added to the blocked
exceptions queue of the target thread and an OS-specific mechanism will be
used to attempt to cause the foreign call to return:
Unix systems
The thread making the foreign call is sent a ``SIGPIPE`` signal
......@@ -333,7 +334,9 @@ Windows systems
Once the system call is successfully interrupted, the surrounding
code must return control out of the ``foreign import``, back into Haskell code,
so that the ``throwTo`` Haskell exception can be raised there.
so that any blocked exception can be raised if the masking state
of the thread allows it. Being under mask gives the Haskell code an opportunity
to detect and react to the interrupt error code from the c call.
If the foreign code simply retries the system call directly without returning
back to Haskell, then the intended effect of `interruptible` disappears
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment