|
Boost Users : |
Subject: [Boost-users] interrupt a blocking stream read
From: Chris Stankevitz (chrisstankevitz_at_[hidden])
Date: 2012-08-17 15:29:10
I am attempting to interrupt a blocking stream read.
The below code doesn't work since std::istream::read is not a valid
boost thread interruption point.
Can someone recommend a way to get something like this work work,
preferably using boost's cross-platform constructs?
Thank you,
Chris
===
void f()
{
try
{
char c[999999999];
cin.read(c, 999999999);
}
catch (boost::thread_interrupted)
{
}
}
int main()
{
boost::thread t(f);
f.interrupt();
f.join()
return 0;
}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net