From ee21a6940d4a8edb758187352ae717bbe7b1b825 Mon Sep 17 00:00:00 2001 From: sc Date: Mon, 4 Dec 2000 13:21:52 +0000 Subject: Added automatic flush --- comm/BufStream.cc | 54 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 6 deletions(-) (limited to 'comm/BufStream.cc') diff --git a/comm/BufStream.cc b/comm/BufStream.cc index 80bbdea..ceae199 100644 --- a/comm/BufStream.cc +++ b/comm/BufStream.cc @@ -1,16 +1,17 @@ /* - * The Unix Channel + * Ivy League * - * by Michel Beaudouin-Lafon + * Buffered streams * - * Copyright 1990-1997 + * Copyright 1990-2000 * Laboratoire de Recherche en Informatique (LRI) + * Centre d'Etudes de la Navigation Aerienne (CENA) * - * Buffered streams + * by Stephane Chatty + * portions of code by Michel Beaudouin-Lafon * * $Id$ - * $CurLog$ - * Created from bits of MsgStream.cc + * */ #include "BufStream.h" @@ -138,36 +139,48 @@ void IvlBufStream :: WriteLong (lword l) { OutBuffer << l; + if (Sync || OutBuffer.BufLength () >= OutSize) + Flush (); } void IvlBufStream :: WriteShort (sword s) { OutBuffer << s; + if (Sync || OutBuffer.BufLength () >= OutSize) + Flush (); } void IvlBufStream :: WriteByte (byte b) { OutBuffer << b; + if (Sync || OutBuffer.BufLength () >= OutSize) + Flush (); } void IvlBufStream :: WriteChar (char c) { OutBuffer << c; + if (Sync || OutBuffer.BufLength () >= OutSize) + Flush (); } void IvlBufStream :: WriteString (const char* s) { OutBuffer << s; + if (Sync || OutBuffer.BufLength () >= OutSize) + Flush (); } void IvlBufStream :: WriteBuf (const byte* b, int n) { OutBuffer.WriteBuf (b, n); + if (Sync || OutBuffer.BufLength () >= OutSize) + Flush (); } bool @@ -212,3 +225,32 @@ IvlBufStream :: ReadBuf (byte* b, int n) return InBuffer.ReadBuf (b, n); } + +#ifdef DOC +/*? +This function defines the size of the output buffer that triggers automatic flushing +in asynchronous mode. By default the flush size is the maximum size of the +output buffer. As a consequence, it is changed by \fun{OutBuffer}. +?*/ +void +IvlBufStream :: FlushSize (int n) +{ } + +/*?nextdoc?*/ +void +IvlBufStream :: SetSyncMode (bool s) +{ } + +/*? +A buffered stream can be in synchronous or asynchronous mode. +In asynchronous mode output is buffered while in synchronous mode it is not. +Synchronous mode is usually less efficient than asynchronous mode +because it makes more system calls to transfer data; +however synchronous mode can be useful for debugging applications. +?*/ +bool +IvlBufStream :: GetSyncMode () +{ } + +#endif /* DOC */ + -- cgit v1.1