12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273(** Useful shortcuts *)moduleU=ExtUnix.SpecificmoduleEnum=ExtEnumlet($)fg=funx->f(gx)let($$)fg=funxy->f(gx)(gy)let(!!)=Lazy.forcemoduleF1=structlet(@@)fg=funx->f@@g@@xlet(|>)fg=funx->x|>f|>gendexternalid:'a->'a="%identity"externalidentity:'a->'a="%identity"letflipfxy=fyxletsomex=Somexletconstx=fun()->xletapply2f=fun(x,y)->fx,fyletprintfnfmt=Printf.ksprintfprint_endlinefmtleteprintfnfmt=Printf.ksprintfprerr_endlinefmtletcurryfab=f(a,b)letuncurryf(a,b)=fabmoduleFresh(T:sigtypetvalcompare:t->t->intend)()=structtypet=T.tletinject=idletproject=idletinject_list=idletproject_list=idletcompare=T.compareletequalab=T.compareab=0letmapfx=inject@@f@@projectxletmap2fxy=inject@@f(projectx)(projecty)endlet(+=)ab=a:=!a+blet(-=)ab=a:=!a-blettucklx=l:=x::!lletconslx=x::lletroundf=letbot=floorfiniff-.bot<0.5thenbotelsebot+.1.letatoinamev=tryint_of_stringvwith_->Exn.fail"%s %S not integer"namevletcall_me_maybefx=matchfwith|None->()|Somef->fx(*
If libev backend is available, do nothing (lwt uses it as default).
Otherwise, prefer poll over select, because select can only monitor fds up to 1024,
and poll is guaranteed to be available without the fd limitation.
*)let()=matchLwt_engine.id()with|Lwt_engine.Engine_id__libev_->()|Lwt_engine.Engine_id__select->(* prefer poll over select, because select can only monitor fds up to 1024,
and poll is guaranteed to be available without the fd limitation. *)Lwt_engine.set@@newLwt_engines.poll|Lwt_engine.Engine_id__poll->()|_->(* unknown engine*)()