From 5711964481f5e0953ceca6aea81d69770decd4ed Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 3 Jun 2008 11:28:16 +0000 Subject: [PATCH] Added unit test to smoke out a thread issue with using ofstream("/dev/null") inside osg::notify() --- examples/osgunittests/osgunittests.cpp | 63 +++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/examples/osgunittests/osgunittests.cpp b/examples/osgunittests/osgunittests.cpp index e758b2fa6..e061d5b8e 100644 --- a/examples/osgunittests/osgunittests.cpp +++ b/examples/osgunittests/osgunittests.cpp @@ -412,7 +412,49 @@ void testQuat(const osg::Vec3d& quat_scale) class MyThread : public OpenThreads::Thread { public: - void run(void) { } + void run(void) { } +}; + +class NotifyThread : public OpenThreads::Thread { +public: + + NotifyThread(osg::NotifySeverity level, const std::string& message): + _done(false), + _level(level), + _message(message) {} + + ~NotifyThread() + { + _done = true; + while(isRunning()) + { + OpenThreads::Thread::YieldCurrentThread(); + } + } + + void run(void) + { + std::cout << "Entering thread ..." <<_message<< std::endl; + + unsigned int count=0; + + while(!_done) + { + ++count; +#if 1 + osg::notify(_level)<<_message<