ocamllabs/ocaml-ctypes — pull request #171 by yallop (2014-08-09 17:08:54+00:00)
Title: Support for acquiring the runtime lock in callbacks

Threads that call from C into OCaml [must hold the runtime lock during the call][runtime-lock-requirements]. There are two cases where the lock needs to be acquired explicitly:

* The call is made from a thread other than the main thread, or
* The call is made from a C function that was called while the runtime lock was released.

This pull request extends the changes in #164 to add support for acquiring the lock in a callback via the [runtime_lock:bool][runtime_lock_argument] argument to [funptr].

[runtime-lock-requirements]: http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual033.html#htoc293
[runtime_lock_argument]: https://github.com/yallop/ocaml-ctypes/blob/fc85a75f2/src/ctypes-foreign-unthreaded/foreign.mli#L51