Commit ee6444ed authored by Rob Earhart's avatar Rob Earhart Committed by Robert Kimball

Make debug logging threadsafe (#1977)

* Make debug logging threadsafe

* Add nil stream comments
parent feef3e04
......@@ -28,9 +28,23 @@
using namespace std;
using namespace ngraph;
namespace
{
class NilStreamBuf final : public streambuf
{
// N.B. We derive from the base streambuf implementation, in
// which underflow() and overflow() both return
// Traits::eof() -- any access returns a failure.
};
}
ostream& ngraph::get_nil_stream()
{
static stringstream nil;
// N.B. When debug logging is disabled, multiple threads may
// access the nil stream simultaneously, so it's important to
// return a threadsafe nil stream implementation.
static NilStreamBuf nil_buf;
static ostream nil{&nil_buf};
return nil;
}
......
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