Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file lwt_fmt.ml
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182(* This file is part of Lwt, released under the MIT license. See LICENSE.md for
details, or visit https://github.com/ocsigen/lwt/blob/master/LICENSE.md. *)openLwt.Infixtypeformatter={commit:unit->unitLwt.t;fmt:Format.formatter;}letwrite_pendingppft=ppft.commit()letflushppft=Format.pp_print_flushppft.fmt();ppft.commit()letmake_formatter~commit~fmt()={commit;fmt}letget_formatterx=x.fmt(** Stream formatter *)typeorder=|Stringofstring*int*int|Flushletmake_stream()=letstream,push=Lwt_stream.create()inletout_stringsij=push@@Some(String(s,i,j))andflush()=push@@SomeFlushinletfmt=Format.make_formatterout_stringflushin(* Not sure about that one *)Gc.finalise(fun_->pushNone)fmt;letcommit()=Lwt.return_unitinstream,make_formatter~commit~fmt()(** Channel formatter *)letwrite_orderoc=function|String(s,i,j)->Lwt_io.write_from_string_exactlyocsij|Flush->Lwt_io.flushocletrecwrite_ordersocqueue=ifQueue.is_emptyqueuethenLwt.return_unitelseleto=Queue.popqueueinwrite_orderoco>>=fun()->write_ordersocqueueletof_channeloc=letq=Queue.create()inletout_stringsij=Queue.push(String(s,i,j))qandflush()=Queue.pushFlushqinletfmt=Format.make_formatterout_stringflushinletcommit()=write_ordersocqinmake_formatter~commit~fmt()(** Printing functions *)letkfprintfkppftfmt=Format.kfprintf(fun_ppf->kppft@@ppft.commit())ppft.fmtfmtletikfprintfkppftfmt=Format.ikfprintf(fun_ppf->kppft@@Lwt.return_unit)ppft.fmtfmtletfprintfppftfmt=kfprintf(fun_t->t)ppftfmtletifprintfppftfmt=ikfprintf(fun_t->t)ppftfmtletstdout=of_channelLwt_io.stdoutletstderr=of_channelLwt_io.stderrletprintffmt=fprintfstdoutfmtleteprintffmt=fprintfstderrfmt