From: <ba...@us...> - 2006-06-11 23:31:53
|
Revision: 341 Author: bardtx Date: 2006-06-11 16:31:48 -0700 (Sun, 11 Jun 2006) ViewCVS: http://svn.sourceforge.net/cadcdev/?rev=341&view=rev Log Message: ----------- tiki: add a bit more thread safety to EventCollector; this piece still isn't 100% correct because it could destruct after a HID callback is in progress but before the callback method is actually called. Modified Paths: -------------- tiki/src/hid/eventcollector.cpp Modified: tiki/src/hid/eventcollector.cpp =================================================================== --- tiki/src/hid/eventcollector.cpp 2006-06-11 23:30:40 UTC (rev 340) +++ tiki/src/hid/eventcollector.cpp 2006-06-11 23:31:48 UTC (rev 341) @@ -24,11 +24,15 @@ } void EventCollector::start() { + Thread::AutoLock lock(m_mutex); + assert( m_cookie < 0 ); m_cookie = callbackReg(hidCallbackStatic, this); } void EventCollector::stop() { + Thread::AutoLock lock(m_mutex); + assert( m_cookie >= 0 ); callbackUnreg(m_cookie); m_cookie = -1; @@ -57,7 +61,8 @@ void EventCollector::hidCallback(const Event & evt) { Thread::AutoLock lock(m_mutex); - m_events.push(evt); + if (m_cookie >= 0) + m_events.push(evt); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |