| 263 | } |
| 264 | |
| 265 | inline |
| 266 | void TaskQueue::doEnqueue(ITask::Ptr task) |
| 267 | { |
| 268 | //NOTE: _queueIt remains unchanged following this operation |
| 269 | _stats.incPostedCount(); |
| 270 | _stats.incNumElements(); |
| 271 | bool isEmpty = _waitQueue.empty(); |
| 272 | if (task->isHighPriority()) |
| 273 | { |
| 274 | //insert before the current position. If _queueIt == begin(), then the new |
| 275 | //task will be at the head of the queue. |
| 276 | _waitQueue.emplace_front(std::static_pointer_cast<Task>(task)); |
| 277 | } |
| 278 | else |
| 279 | { |
| 280 | //insert after the current position. If next(_queueIt) == end() |
| 281 | //then the new task will be the last element in the queue |
| 282 | _waitQueue.emplace_back(std::static_pointer_cast<Task>(task)); |
| 283 | } |
| 284 | if (task->isHighPriority()) |
| 285 | { |
| 286 | _stats.incHighPriorityCount(); |
| 287 | } |
| 288 | if (isEmpty) |
| 289 | { |
| 290 | //signal on transition from 0 to 1 element only |
| 291 | signalEmptyCondition(false); |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | inline |
| 296 | ITask::Ptr TaskQueue::dequeue(std::atomic_bool& hint) |
nothing calls this directly
no test coverage detected