Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

14.3 Implicit Synchronization Using the unitbuf Format Flag

You can achieve a kind of automatic synchronization for output files by using the format flag ios_base::unitbuf. It causes an output stream to flush its buffer after each output operation as follows:

//1Set the unitbuf format flag.
//2After each insertion into the shared file /tmp/fil, the buffer is automatically flushed, and the output is available to other streams that read from the same file.

Since it is not overly efficient to flush after every single token that is inserted, you might consider switching off the unitbuf flag for a lengthy output that is not supposed to be read partially.

//1Switch off the unitbuf flag. Alternatively, using manipulators, you can say ostr << nounitbuf;
//2Flush the buffer and switch on the unitbuf flag again. Alternatively, you can say ostr << flush << unitbuf;

Previous fileTop of DocumentContentsIndexNext file

OEM Edition, ©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.