MCPcopy Create free account
hub / github.com/apache/incubator-pegasus / dequeue

Method dequeue

src/runtime/task/hpc_task_queue.cpp:53–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53task *hpc_concurrent_task_queue::dequeue(int &batch_size)
54{
55 batch_size = _sema.waitMany(batch_size);
56 if (batch_size == 0) {
57 return nullptr;
58 }
59 task *head = nullptr, *last = nullptr;
60 auto out = boost::make_function_output_iterator([&head, &last](task *in) {
61 if (last) {
62 last->next = in;
63 } else {
64 head = in;
65 }
66
67 last = in;
68 last->next = nullptr;
69 });
70 auto count = batch_size;
71 do {
72 for (auto &qs : _queues) {
73 count -= qs.q.try_dequeue_bulk(out, count);
74 if (count == 0) {
75 break;
76 }
77 }
78 } while (count != 0);
79 return head;
80}
81}
82}

Callers 2

loopMethod · 0.45
send_messageFunction · 0.45

Calls

no outgoing calls

Tested by 1

send_messageFunction · 0.36