- Timestamp:
- 06/05/13 21:12:34 (11 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/StateMachineImp.cc
r16726 r16730 167 167 const lock_guard<mutex> guard(fMutex); 168 168 fEventQueue.emplace_back(cmd); 169 fCond.notify_one(); 169 170 } 170 171 … … 1008 1009 SetCurrentState(kSM_Ready, "by Run()"); 1009 1010 1010 while (!fExitRequested) 1011 std::unique_lock<std::mutex> lock(fMutex); 1012 fMutex.unlock(); 1013 1014 while (1) 1011 1015 { 1012 usleep(1); 1016 fMutex.lock(); 1017 if (IsQueueEmpty()) 1018 fCond.wait_for(lock, chrono::microseconds(10000)); 1019 fMutex.unlock(); 1020 1021 if (fExitRequested) 1022 break; 1023 1013 1024 if (dummy) 1014 1025 continue; 1015 1026 1027 // If the command stack is empty go on with processing in the 1028 // current state 1029 if (!IsQueueEmpty()) 1030 { 1031 // Pop the next command which arrived from the stack 1032 const shared_ptr<Event> cmd(PopEvent()); 1033 if (!HandleEvent(*cmd)) 1034 break; 1035 } 1036 1016 1037 // Execute a step in the current state of the state machine 1017 1038 if (!HandleNewState(Execute(), 0, "by Execute-command")) 1018 break;1019 1020 // If the command stack is empty go on with processing in the1021 // current state1022 if (IsQueueEmpty())1023 continue;1024 1025 // Pop the next command which arrived from the stack1026 const shared_ptr<Event> cmd(PopEvent());1027 1028 if (!HandleEvent(*cmd))1029 1039 break; 1030 1040 } -
trunk/FACT++/src/StateMachineImp.h
r16726 r16730 7 7 #include <vector> 8 8 #include <memory> 9 #include <condition_variable> 9 10 10 11 #include "MainImp.h" … … 49 50 std::mutex fMutexEvt; /// Mutex to ensure thread-safe access to the command fifo 50 51 52 std::condition_variable fCond; /// Conditional to signal run the an event is waiting 53 51 54 bool fBufferEvents; /// Flag if events should be buffered outside the event loop 52 55
Note:
See TracChangeset
for help on using the changeset viewer.