12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273(* Copyright (C) 2018--2019 Petter A. Urkedal <paurkedal@gmail.com>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version, with the OCaml static compilation exception.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*)openCaqti_common_privmoduleSystem=structtype'afuture='alet(>>=)xf=fxlet(>|=)xf=fxletreturnx=xletjoin(_:unitlist)=()moduleMvar=structtype'at='aoptionrefletcreate()=refNoneletstorexv=v:=Somexletfetchv=(match!vwith|None->failwith"Attempt to fetch empty mvar from blocking client."|Somex->x)endmoduleLog=structtype'alog='aLogs.logleterr?(src=default_log_src)=Logs.err~srcletwarn?(src=default_log_src)=Logs.warn~srcletinfo?(src=default_log_src)=Logs.info~srcletdebug?(src=default_log_src)=Logs.debug~srcendmoduleUnix=structtypefile_descr=Unix.file_descrletwrap_fdffd=ffdletpoll?(read=false)?(write=false)?(timeout=-1.0)fd=letread_fds=ifreadthen[fd]else[]inletwrite_fds=ifwritethen[fd]else[]inletread_fds,write_fds,_=Unix.selectread_fdswrite_fds[]timeoutin(read_fds<>[],write_fds<>[],read_fds=[]&&write_fds=[])endmodulePreemptive=structletdetachfx=fxletrun_in_mainf=f()endmoduleStream=Caqti_stream.Make(structtype'afuture='alet(>>=)xf=fxlet(>|=)xf=fxletreturnx=xend)endtype'afuture='aincludeCaqti_connect.Make_unix(System)letor_fail=function|Okx->x|Error(#Caqti_error.taserr)->raise(Caqti_error.Exnerr)