method sourcering_stop =
match state with
| `Running id ->
Mutex.lock wait_m ;
state <- `Tired ;
Mutex.unlock wait_m ;
(* One signal is enough since there is only one half of
* the process waiting for us, the other half cannot be
* called concurrently with this method. *)
Condition.signal wait_c ;
Thread.join id ;
state <- `Idle
| `Tired | `Idle -> assert false
| `Crashed -> ()