Changeset 4483 for source/ariba/utility/system/SystemQueue.cpp
- Timestamp:
- Jun 25, 2009, 11:06:52 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/utility/system/SystemQueue.cpp
r3690 r4483 130 130 131 131 // cause the thread to exit 132 running = false; 133 itemsAvailable.notify_all(); 132 { 133 boost::mutex::scoped_lock lock(queueMutex); 134 running = false; 135 136 while( eventsQueue.size() > 0 ){ 137 eventsQueue.erase( eventsQueue.begin() ); 138 } 139 140 itemsAvailable.notify_all(); 141 } 134 142 135 143 // wait that the thread has exited … … 139 147 delete queueThread; 140 148 queueThread = NULL; 141 142 while( eventsQueue.size() > 0 ){143 eventsQueue.erase( eventsQueue.begin() );144 }145 149 } 146 150 … … 151 155 152 156 void SystemQueue::QueueThread::insert( const SystemEvent& event, uint32_t delay ){ 153 { 154 boost::mutex::scoped_lock lock( queueMutex ); 155 156 eventsQueue.push_back( event ); 157 eventsQueue.back().scheduledTime = boost::posix_time::microsec_clock::local_time(); 158 eventsQueue.back().delayTime = delay; 159 eventsQueue.back().remainingDelay = delay; 160 161 onItemInserted( event ); 162 itemsAvailable.notify_all(); 163 } 157 158 // if this is called from a module that is currently handling 159 // a thread (called from SystemQueue::onNextQueueItem), the 160 // thread is the same anyway and the mutex will be already 161 // aquired, otherwise we aquire it now 162 163 boost::mutex::scoped_lock lock( queueMutex ); 164 165 eventsQueue.push_back( event ); 166 eventsQueue.back().scheduledTime = boost::posix_time::microsec_clock::local_time(); 167 eventsQueue.back().delayTime = delay; 168 eventsQueue.back().remainingDelay = delay; 169 170 onItemInserted( event ); 171 itemsAvailable.notify_all(); 164 172 } 165 173 … … 177 185 while ( obj->eventsQueue.empty() && obj->running ){ 178 186 179 const boost::system_time duration =180 boost::get_system_time() +181 boost::posix_time::milliseconds(40);187 // const boost::system_time duration = 188 // boost::get_system_time() + 189 // boost::posix_time::milliseconds(100); 182 190 183 191 obj->itemsAvailable.wait( lock ); … … 185 193 } 186 194 195 // 187 196 // work all the items that are currently in the queue 188 189 while( !obj->eventsQueue.empty() ) { 190 191 // fetch the first item in the queue and deliver it to the 192 // queue handler 197 // 198 199 while( !obj->eventsQueue.empty() && obj->running ) { 200 201 // fetch the first item in the queue 202 // and deliver it to the queue handler 193 203 SystemEvent ev = obj->eventsQueue.front(); 194 204 obj->eventsQueue.erase( obj->eventsQueue.begin() ); 195 205 196 { 197 // unlock the queue to that an event handler 198 // can insert new items into the queue 199 // obj->queueMutex.unlock(); 200 obj->onNextQueueItem( ev ); 201 // obj->queueMutex.lock(); 202 } 206 // call the queue and this will 207 // call the actual event handler 208 obj->onNextQueueItem( ev ); 203 209 204 210 } // !obj->eventsQueue.empty() ) 205 211 } // while (obj->running) 212 213 logging_debug("system queue exited"); 206 214 } 207 215
Note:
See TracChangeset
for help on using the changeset viewer.