[Quickfix-developers] New synchronization questions/comments
Brought to you by:
orenmnero
From: Gene G. <mus...@ya...> - 2002-09-04 17:52:37
|
I am looking at the ThreadedSocketAcceptor class, and I have noticed that although onStop will likely to run while onStart is looping, the access to m_stop and m_socket is not guarded. The shutdown solution that works in my applications uses portable boost library code and condition variables class App : ...{ protected: boost::condition m_ShutdownMonitor; boost::recursive_mutex m_AppMutex; bool m_Shutdown; } void App::Shutdown() { Locker lock (m_AppMutex); m_Shutdown = true; m_ShutdownMonitor.notify_all(); } void App::onRun() { Locker lock(m_AppMutex); while (!m_Shutdown) { m_ShutdownMonitor.wait(lock); } } __________________________________________________ Do You Yahoo!? Yahoo! Finance - Get real-time stock quotes http://finance.yahoo.com |