* Enqueues a task. Tasks are guaranteed to be executed in the order * they were enqueued in except if there is more than one worker thread or when * allowInterleaved is true in which case the new task might be run * immediately if it's being enqueued from within the WorkQueue thread. */
| 86 | * immediately if it's being enqueued from within the WorkQueue thread. |
| 87 | */ |
| 88 | void WorkQueue::Enqueue(std::function<void ()>&& function, WorkQueuePriority priority, |
| 89 | bool allowInterleaved) |
| 90 | { |
| 91 | bool wq_thread = IsWorkerThread(); |
| 92 | |
| 93 | if (wq_thread && allowInterleaved) { |
| 94 | function(); |
| 95 | |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | auto lock = AcquireLock(); |
| 100 | EnqueueUnlocked(lock, std::move(function), priority); |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Waits until all currently enqueued tasks have completed. This only works reliably |
no outgoing calls
no test coverage detected