12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485externalyield:unit->unit@@portable="caml_thread_yield"(* Like [Stdlib.raise], but [portable], and the value it never returns is also
[portable unique] *)externalreraise:('a:value_or_null).exn->'a@portableunique@@portable="%reraise"moduleM=structtypet:valuemodcontendedportableexternalcreate:unit->t@@portable="caml_blocking_mutex_new"externallock:t@local->unit@@portable="caml_blocking_mutex_lock"externalunlock:t@local->unit@@portable="caml_blocking_mutex_unlock"endmoduleMutex=structtypet:valuemodcontendedportable={mutex:M.t;mutablepoisoned:bool}[@@unsafe_allow_any_mode_crossing"Unsafe mode crossing by design. The mutable [poisoned] field is protected by the \
[mutex]. "]let[@inline]create()={mutex=M.create();poisoned=false}exceptionPoisonedlet[@inlinenever]poison_and_reraiset~exn=t.poisoned<-true;M.unlockt.mutex;reraiseexn;;let[@inline]with_lockt~f=M.lockt.mutex;matcht.poisonedwith|true->M.unlockt.mutex;reraisePoisoned|false->(matchf()with|x->M.unlockt.mutex;x|exceptionexn->poison_and_reraiset~exn[@nontail]);;let[@inline]destroyt=M.lockt.mutex;matcht.poisonedwith|true->M.unlockt.mutex;reraisePoisoned|false->t.poisoned<-true;M.unlockt.mutex;;endmoduleCondition=structtypet:valuemodcontendedportableexternalcreate:unit->t@@portable="caml_blocking_condition_new"externalwait:t->M.t->unit@@portable="caml_blocking_condition_wait"externalsignal:t->unit@@portable="caml_blocking_condition_signal"externalbroadcast:t->unit@@portable="caml_blocking_condition_broadcast"let[@inline]waitt~(mutex:Mutex.t)=(* Check that the mutex is not poisoned. It's safe to do so without locking: either we
hold the [key] because it's locked, or because it's poisoned. *)matchmutex.poisonedwith|true->reraiseMutex.Poisoned|false->waittmutex.mutex;(* Check that the mutex wasn't poisoned again while we were waiting. If it was, we
can't return the key. *)(matchmutex.poisonedwith|true->reraiseMutex.Poisoned|false->());;end