Commit 88189532 authored by Davis King's avatar Davis King

Made the bridge code a little more robust.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%404282
parent 8808589d
...@@ -192,11 +192,22 @@ namespace dlib ...@@ -192,11 +192,22 @@ namespace dlib
// tell the threads to terminate // tell the threads to terminate
stop(); stop();
// save current pipe enabled status so we can restore it to however
// it was before this destructor ran.
bool transmit_enabled = true;
bool receive_enabled = true;
// make any calls blocked on a pipe return immediately. // make any calls blocked on a pipe return immediately.
if (transmit_pipe) if (transmit_pipe)
{
transmit_enabled = transmit_pipe->is_dequeue_enabled();
transmit_pipe->disable_dequeue(); transmit_pipe->disable_dequeue();
}
if (receive_pipe) if (receive_pipe)
{
receive_enabled = receive_pipe->is_enqueue_enabled();
receive_pipe->disable_enqueue(); receive_pipe->disable_enqueue();
}
{ {
auto_mutex lock(m); auto_mutex lock(m);
...@@ -210,9 +221,9 @@ namespace dlib ...@@ -210,9 +221,9 @@ namespace dlib
// wait for all the threads to terminate. // wait for all the threads to terminate.
wait(); wait();
if (transmit_pipe) if (transmit_pipe && transmit_enabled)
transmit_pipe->enable_dequeue(); transmit_pipe->enable_dequeue();
if (receive_pipe) if (receive_pipe && receive_enabled)
receive_pipe->enable_enqueue(); receive_pipe->enable_enqueue();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment