Module In_thread.When_finished

When_finished describes how In_thread.run f behaves when the helper thread finishes f ().

type t =
| Notify_the_scheduler

The helper thread notifies the Async scheduler that the result is ready, so that the scheduler will wake up in a timely manner and run a cycle.

| Take_the_async_lock

The helper thread blocks until it can acquire the Async lock, at which point it runs a cycle.

| Try_to_take_the_async_lock

If the thread_pool_cpu_affinity is Inherit, then the helper hread tries to take the Async lock and run a cycle. If the thread_pool_cpu_affinity is Cpuset or the helper thread is unable to acquire the Async lock, then it behaves as in Notify_the_scheduler.

val all : t list
val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
val default : t Core.ref

default defines the default value used for In_thread.run's ?when_finished argument. Changes to default affect subsequent calls to In_thread.run. Initially, default = Try_to_take_the_async_lock, which typically leads to better latency by avoiding an extra context switch to pass the result to the Async scheduler thread. However, there are applications (e.g. jenga) where Notify_the_scheduler leads to significantly higher throughput by greatly decreasing the total number of Async cycles.