public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
* C++ question - string_ostream - can you help?
@ 2000-07-15  6:59 Dennis Foreman
  0 siblings, 0 replies; 2+ messages in thread
From: Dennis Foreman @ 2000-07-15  6:59 UTC (permalink / raw)
  To: Pthread-List, Open Discussion Mailing List

Hi all,
Sorry to have bothered you. Found it myself. Needed an "ends" at the end of
my streams, as well as an "endl". But if you know of a better way to do what
I intended, please let me know.

regards,
D. J. Foreman
website: http://www.cs.binghamton.edu/~foreman/start.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

* C++ question - string_ostream - can you help?
@ 2000-07-15  6:41 Dennis Foreman
  0 siblings, 0 replies; 2+ messages in thread
From: Dennis Foreman @ 2000-07-15  6:41 UTC (permalink / raw)
  To: Pthread-List, Open Discussion Mailing List

I have a function (below), that I use to (hopefully) synchronize my output
from multiple threads to a single ofstream.

Unfortunately, I am getting strange results in the output: looks like data
is being either overlayed, or the stream is not being flushed. Can you offer
any suggestions?

pthread_mutex_t mystream_lock=PTHREAD_MUTEX_INITIALIZER;
ofstream dcout;
main()
{string_ostream dbgout;
	dbgout<<"aha"<<endl;
	myout(dbgout);
}
void myout(string_ostream& out)
	{pthread_mutex_lock(&mystream_lock);
	out.flush();
	dcout<<out.str()<<flush; // debug stream file. NOT terminal I/O.
	 // str freezes the array!!!
	out.rdbuf()->freeze(0);
	out.seekp(0);
	 pthread_mutex_unlock(&mystream_lock);
	}

regards,
D. J. Foreman
website: http://www.cs.binghamton.edu/~foreman/start.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-07-15  6:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-15  6:59 C++ question - string_ostream - can you help? Dennis Foreman
  -- strict thread matches above, loose matches on Subject: below --
2000-07-15  6:41 Dennis Foreman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).