summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsc2000-12-04 13:21:52 +0000
committersc2000-12-04 13:21:52 +0000
commitee21a6940d4a8edb758187352ae717bbe7b1b825 (patch)
tree6b56ac5aee58146a58b3f437d281a803c59da98f
parentf05094730c6d8ad3af4bb8fb94db95822ec20845 (diff)
downloadivy-league-ee21a6940d4a8edb758187352ae717bbe7b1b825.zip
ivy-league-ee21a6940d4a8edb758187352ae717bbe7b1b825.tar.gz
ivy-league-ee21a6940d4a8edb758187352ae717bbe7b1b825.tar.bz2
ivy-league-ee21a6940d4a8edb758187352ae717bbe7b1b825.tar.xz
Added automatic flush
-rw-r--r--comm/BufStream.cc54
1 files changed, 48 insertions, 6 deletions
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 */
+