Hi all,
I want to use a single std::stringbuf for writing (by a std::ostream)
and for reading (by a std::istream), concurrently in two threads.
This came to my mind, because the code for reading should be as with any other istream and cannot be changed.
Now my problem is, that a do not get any data in the reading loop
std::ofstream tempfile("test. pdf",
std::ios_base:: out | std::ios_base:: trunc | std::ios_base:: binary);
while (!is->eof()) {
is->read(buffer, bufferSize);
tempfile.write( buffer, is->gcount());
tempfile.flush;
}
The writing thread proceeds as expected and finally finishes writing.
Any hints? What are my misconceptions?
Thanks,
Christoph
I want to use a single std::stringbuf for writing (by a std::ostream)
and for reading (by a std::istream), concurrently in two threads.
This came to my mind, because the code for reading should be as with any other istream and cannot be changed.
Now my problem is, that a do not get any data in the reading loop
std::ofstream tempfile("test. pdf",
std::ios_base:: out | std::ios_base:: trunc | std::ios_base:: binary);
while (!is->eof()) {
is->read(buffer, bufferSize);
tempfile.write( buffer, is->gcount());
tempfile.flush;
}
The writing thread proceeds as expected and finally finishes writing.
Any hints? What are my misconceptions?
Thanks,
Christoph
Comment