Module Async_unix__.In_thread
module Priority : module type of Linux_ext.Priority with type Priority.t = Linux_ext.Priority.tmodule Helper_thread : sig ... end- val pipe_of_squeue : 'a Squeue.t -> 'a Async_kernel.Pipe.Reader.t
- pipe_of_squeue squeuereturns a pipe- pand consumes the contents- squeue, placing them in- p. It repeatedly grabs everything from- squeue, places it in- p, and then waits for pushback on- p.
- module When_finished : sig ... end
- When_finisheddescribes how- In_thread.run fbehaves when the helper thread finishes- f ().
- val run : ?priority:Priority.t -> ?thread:Helper_thread.t -> ?when_finished:When_finished.t -> ?name:string -> (unit -> 'a) -> 'a Async_kernel.Deferred.t
- run ?priority ?thread ?name fruns- f ()in a separate thread outside Async and returns the result as a Deferred in the Async world. If- f ()raises an exception (asynchronously, since it is another thread) then that exception will be raised to the monitor that called- run.- WARNING: Async code MUST NOT be used from within - f. By Async code we mean pretty-much all functions of libraries making use of Async. Only a few functions of the Async library can be called inside- In_thread.run. These are explicitly marked as such, using the phrase "thread-safe".- If - threadis not supplied, then any thread from the thread pool could be used. If you need to run routines in a specific thread (as is required by some libraries like Sqlite), you should create a helper thread and supply it to- run.- If - priorityis supplied, the priority of the thread in the linux scheduler will be set to- priorityfor the duration of- f (), provided the thread is allowed to do so (see- man setpriority).- If you call - runseveral times with the same helper thread, the- f ()calls will run in sequence, in the order in which they are supplied to- run. Each- f ()will complete (return or raise) before another- f ()starts.- For example, if you do: - let () = run ~thread f1; run ~thread f2; run ~thread f3;- Then the thread will run - f1 ()to completion, then- f2 ()to completion, then- f3 ()to completion.- If - nameis supplied, the name of the thread will be set to it for the duration of the execution of- f ().- when_finisheddescribes how the helper thread behaves once- f ()has completed. Its default value is the value of- When_finished.defaultwhen- runis called.
- val syscall : name:string -> (unit -> 'a) -> ('a, exn) Core.Result.t Async_kernel.Deferred.t
- syscall fruns f, which should be a single system call, and returns the result, handling the restarting of interrupted system calls. To avoid race conditions, the- fsupplied to- syscallshould just make a system call. That way, everything else is done holding the Async lock.
- val syscall_exn : name:string -> (unit -> 'a) -> 'a Async_kernel.Deferred.t