- Timestamp:
- 10/18/13 22:21:27 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcore/Queue.h
r17227 r17268 29 29 kStop, 30 30 kAbort, 31 kTrigger 31 kTrigger, 32 kPrompt 33 32 34 }; 33 35 … … 184 186 } 185 187 188 bool enablePromptExecution() 189 { 190 const std::lock_guard<std::mutex> lock(fMutex); 191 if (fState!=kIdle || fSize>0) 192 return false; 193 194 fState = kPrompt; 195 return true; 196 } 197 198 bool disablePromptExecution() 199 { 200 const std::lock_guard<std::mutex> lock(fMutex); 201 if (fState!=kPrompt) 202 return false; 203 204 fState = kIdle; 205 return true; 206 } 207 208 bool setPromptExecution(bool state) 209 { 210 return state ? enablePromptExecution() : disablePromptExecution(); 211 } 212 213 186 214 bool post(const T &val) 187 215 { 188 216 const std::lock_guard<std::mutex> lock(fMutex); 217 if (fState==kPrompt) 218 return fCallback(val); 189 219 190 220 if (fState==kIdle) … … 216 246 { 217 247 const std::lock_guard<std::mutex> lock(fMutex); 248 if (fState==kPrompt) 249 return fCallback(T(__args...)); 250 218 251 if (fState==kIdle) 219 252 return false; … … 261 294 return fSize==0; 262 295 } 296 297 bool operator<(const Queue& other) const 298 { 299 return fSize < other.fSize; 300 } 301 263 302 }; 264 303
Note:
See TracChangeset
for help on using the changeset viewer.