MCPcopy Create free account
hub / github.com/bloomberg/quantum / grabWorkItem

Method grabWorkItem

quantum/impl/quantum_io_queue_impl.h:380–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378}
379
380inline
381ITask::Ptr IoQueue::grabWorkItem()
382{
383 static bool grabFromShared = false;
384 ITask::Ptr task = nullptr;
385 grabFromShared = !grabFromShared;
386
387 if (grabFromShared) {
388 //========================= LOCKED SCOPE (SHARED QUEUE) =========================
389 SpinLock::Guard lock((*_sharedIoQueues)[0].getLock());
390 task = (*_sharedIoQueues)[0].dequeue(_isIdle);
391 if (!task)
392 {
393 //========================= LOCKED SCOPE =========================
394 SpinLock::Guard lock(_spinlock);
395 task = dequeue(_isIdle);
396 if (!task)
397 {
398 signalEmptyCondition(true);
399 }
400 }
401 }
402 else {
403 //========================= LOCKED SCOPE =========================
404 SpinLock::Guard lock(_spinlock);
405 task = dequeue(_isIdle);
406 if (!task)
407 {
408 //========================= LOCKED SCOPE (SHARED QUEUE) =========================
409 SpinLock::Guard lock((*_sharedIoQueues)[0].getLock());
410 task = (*_sharedIoQueues)[0].dequeue(_isIdle);
411 if (!task)
412 {
413 signalEmptyCondition(true);
414 }
415 }
416 }
417 return task;
418}
419
420inline
421ITask::Ptr IoQueue::grabWorkItemFromAll()

Callers

nothing calls this directly

Calls 1

dequeueMethod · 0.45

Tested by

no test coverage detected