val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.tThread creation and termination
val create : ('a -> 'b) -> 'a -> tThread.create funct arg creates a new thread of control, in which the function application funct arg is executed concurrently with the other threads of the program. The application of Thread.create returns the handle of the newly created thread. The new thread terminates when the application funct arg returns, either normally or by raising an uncaught exception. In the latter case, the exception is printed on standard error, but not propagated back to the parent thread. Similarly, the result of the application funct arg is discarded and not directly accessible to the parent thread.
val self : unit -> tReturn the thread currently executing.
val id : t -> intReturn the identifier of the given thread. A thread identifier is an integer that identifies uniquely the thread. It can be used to build data structures indexed by threads.
Suspending threads
delay d suspends the execution of the calling thread for d seconds. The other program threads continue to run during this time.
val join : t -> unitjoin th suspends the execution of the calling thread until the thread th has terminated.
val wait_read : Unix.file_descr -> unitSee Thread.wait_write.
val wait_write : Unix.file_descr -> unitSuspend the execution of the calling thread until at least one character is available for reading (Thread.wait_read) or one character can be written without blocking (wait_write) on the given Unix file descriptor.
val wait_timed_read : Unix.file_descr -> float -> boolval wait_timed_write : Unix.file_descr -> float -> boolSame as Thread.wait_read and Thread.wait_write, but wait for at most the amount of time given as second argument (in seconds). Return true if the file descriptor is ready for input/output and false if the timeout expired.
Re-schedule the calling thread without suspending it. This function can be used to give scheduling hints, telling the scheduler that now is a good time to switch to other threads.
Management of signals
val sigmask : Signal.sigprocmask_command -> Signal.t list -> Signal.t listsigmask cmd sigs changes the set of blocked signals for the calling thread. If cmd is `Set, blocked signals are set to those in the list sigs. If cmd is `Block, the signals in sigs are added to the set of blocked signals. If cmd is `Unblock, the signals in sigs are removed from the set of blocked signals. sigmask returns the set of previously blocked signals for the thread.
val wait_signal : Signal.t list -> intwait_signal sigs suspends the execution of the calling thread until the process receives one of the signals specified in the list sigs. It then returns the number of the signal received. Signal handlers attached to the signals in sigs will not be invoked. The signals sigs are expected to be blocked before calling wait_signal.
true iff Thread.create has ever been called, even if there is currently only one running thread.
num_threads () attempts to return the number of currently running threads by parsing /proc. Since this is an operation frought with potential failure, we return an option in cases of failure
Non-portable pthread extensions
val setaffinity_self_exn : (Core_kernel.Int.Set.t -> unit) Core_kernel.Or_error.tSets the core affinity of the currently-running thread to the set specified.
This function is implemented using pthread_setaffinity_np(3), when available. See the man page for situations when this function may return an error, and therefore raise.
val getaffinity_self_exn : (unit -> Core_kernel.Int.Set.t) Core_kernel.Or_error.tGets the core affinity of the currently-running thread.
This function is implemented using pthread_getaffinity_np(3), when available. See the man page for situations when this function may return an error, and therefore raise.
module For_testing : sig ... end