1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677(* Copyright (C) 2018--2021 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=xletfinallyfg=(matchf()with|y->g();y|exceptionexn->g();raiseexn)letjoin(_: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)