Changeset 23b6cf for src/Actions/ActionQueue.cpp
- Timestamp:
- Oct 23, 2014, 4:33:11 PM (10 years ago)
- Children:
- 9a4949
- Parents:
- 7b38d3
- git-author:
- Frederik Heber <heber@…> (08/29/14 09:46:02)
- git-committer:
- Frederik Heber <heber@…> (10/23/14 16:33:11)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/ActionQueue.cpp
r7b38d3 r23b6cf 66 66 #else 67 67 lastActionOk(true), 68 run_thread (boost::bind(&ActionQueue::run, this)),69 run_thread _isIdle(true)68 run_thread_isIdle(true), 69 run_thread(boost::bind(&ActionQueue::run, this)) 70 70 #endif 71 71 { … … 127 127 } 128 128 #else 129 const bool new_run_thread_isIdle = (CurrentAction == actionqueue.size()); 130 mtx_queue.unlock(); 129 131 { 130 boost::lock_guard<boost::mutex> lock(mtx_idle); 131 run_thread_isIdle = (CurrentAction == actionqueue.size()); 132 } 133 mtx_queue.unlock(); 132 boost::lock_guard<boost::mutex> lock(mtx_run_thread_isIdle); 133 run_thread_isIdle = new_run_thread_isIdle; 134 } 134 135 #endif 135 136 } … … 145 146 tempqueue.push_back( newaction ); 146 147 { 147 boost::lock_guard<boost::mutex> lock(mtx_ idle);148 boost::lock_guard<boost::mutex> lock(mtx_run_thread_isIdle); 148 149 run_thread_isIdle = !((CurrentAction != actionqueue.size()) || !tempqueue.empty()); 149 150 } … … 160 161 try { 161 162 #if BOOST_VERSION < 105000 162 run_thread.sleep(boost::get_system_time() + boost::posix_time::milliseconds(100));163 boost::this_thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(100)); 163 164 #else 164 165 boost::this_thread::sleep_for(boost::chrono::milliseconds(100)); … … 176 177 while (status) { 177 178 // boost::this_thread::disable_interruption di; 179 // access actionqueue, hence using mutex 180 mtx_queue.lock(); 178 181 LOG(0, "Calling Action " << actionqueue[CurrentAction]->getName() << " ... "); 179 182 try { … … 195 198 CurrentAction = (size_t)-1; 196 199 } 197 if (lastActionOk) { 198 OBSERVE; 199 NOTIFY(ActionQueued); 200 _lastchangedaction = actionqueue[CurrentAction]; 201 } 202 // access actionqueue, hence using mutex 203 mtx_queue.lock(); 200 // remember action we juse executed 201 const Action *lastaction = actionqueue[CurrentAction]; 204 202 // step on to next action and check for end 205 203 CurrentAction++; … … 209 207 insertTempQueue(); 210 208 status = (CurrentAction != actionqueue.size()); 211 mtx_queue.unlock(); 209 // set last action 210 if (lastActionOk) { 211 OBSERVE; 212 NOTIFY(ActionQueued); 213 _lastchangedaction = lastaction; 214 // unlock before we delve into Observer functions ... 215 mtx_queue.unlock(); 216 } else { 217 mtx_queue.unlock(); 218 } 212 219 } 220 mtx_queue.lock(); 221 const bool new_run_thread_isIdle = !((CurrentAction != actionqueue.size()) || !tempqueue.empty()); 222 mtx_queue.unlock(); 213 223 { 214 boost::lock_guard<boost::mutex> lock(mtx_ idle);215 run_thread_isIdle = !((CurrentAction != actionqueue.size()) || !tempqueue.empty());224 boost::lock_guard<boost::mutex> lock(mtx_run_thread_isIdle); 225 run_thread_isIdle = new_run_thread_isIdle; 216 226 } 217 227 cond_idle.notify_one(); … … 234 244 void ActionQueue::wait() 235 245 { 236 boost::unique_lock<boost::mutex> lock(mtx_ idle);246 boost::unique_lock<boost::mutex> lock(mtx_run_thread_isIdle); 237 247 while(!run_thread_isIdle) 238 248 {
Note:
See TracChangeset
for help on using the changeset viewer.