Module Multicore
Multicore allows spawning preemptively scheduled threads to run on domains running in parallel.
max_domains () is the maximum number of domains. Domains are indexed from 0 to max_domains () - 1.
current_domain () is the index of the domain that the current thread is running on.
type ('a : value_or_null) spawn_result = | Spawned| Failed of 'a * exn @@ many aliased * Printexc.raw_backtrace @@ many aliased
val spawn_on :
('a : value_or_null). domain:int ->
('a @ unique once portable contended -> unit) @ once portable ->
'a @ unique once portable contended ->
'a spawn_result @ unique once portable contended @@ portablespawn_on ~domain action spawns action as a thread running on the specified domain.
The action should handle all exceptions. In case the action raises an exception, it will be allowed to propagate and the uncaught exception handler will be called.
val spawn :
('a : value_or_null). ('a @ unique once portable contended -> unit) @ once portable ->
'a @ unique once portable contended ->
'a spawn_result @ unique once portable contended @@ portablespawn action spawns action as a thread running on some domain.
The action should handle all exceptions. In case the action raises an exception, it will be allowed to propagate and the uncaught exception handler will be called.
The domain used to spawn the thread on is selected semi-probabilistically so as to balance the load per domain.