Skip to Content.
Sympa Menu

charm - [charm] [PATCH] Stream manipulator "flush"

charm AT lists.cs.illinois.edu

Subject: Charm++ parallel programming system

List archive

[charm] [PATCH] Stream manipulator "flush"


Chronological Thread 
  • From: Artem Shvorin <shvorin AT gmail.com>
  • To: charm AT cs.uiuc.edu
  • Subject: [charm] [PATCH] Stream manipulator "flush"
  • Date: Tue, 10 May 2011 21:32:49 +0400
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/charm>
  • List-id: CHARM parallel programming system <charm.cs.uiuc.edu>

Is it possible to have std::ostream as a base class for both CkOutStream and CkErrStream? I see an attempt to do it was unrolled at d34b39ec5796bbf7f99788b82a6f04d95d6b164a due to problem with a few (rare?) C++ implementations. I wonder if the situtation changed. Maybe it's possible to workaround some of those cases...

Otherwise we have to re-implement standard io manipulators. Here is a patch providing the flush manipulator:

---
 src/ck-core/ckstream.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/ck-core/ckstream.h b/src/ck-core/ckstream.h
index 04fed7c..9cf777c 100644
--- a/src/ck-core/ckstream.h
+++ b/src/ck-core/ckstream.h
@@ -43,6 +43,16 @@ class _CkOStream {
       return *this;
     }
 
+    _CkOStream& flush(void) {
+      if(_isErr)
+        CkError("%s", _obuf);
+      else
+        CkPrintf("%s", _obuf);
+      _obuf[0] = '\0';
+      _actlen=1;
+      return *this;
+    }
+
     _CkOStream& operator << (_CkOStream& (*f)(_CkOStream &)) {
       return f(*this);
     }
@@ -78,6 +88,7 @@ class _CkOStream {
 };
 
 static inline _CkOStream& endl(_CkOStream& s)  { return s.endl(); }
+static inline _CkOStream& flush(_CkOStream& s)  { return s.flush(); }
 
 class _CkOutStream : public _CkOStream {
   public:
--
1.5.6.5



  • [charm] [PATCH] Stream manipulator "flush", Artem Shvorin, 05/10/2011

Archive powered by MHonArc 2.6.16.

Top of Page