MCPcopy Create free account
hub / github.com/apache/brpc / add_with_suspend2

Function add_with_suspend2

test/bthread_execution_queue_unittest.cpp:625–644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

623}
624
625int add_with_suspend2(void* meta, bthread::TaskIterator<LongIntTask>& iter) {
626 int64_t* result = (int64_t*)meta;
627 if (iter.is_queue_stopped()) {
628 stopped = true;
629 return 0;
630 }
631 for (; iter; ++iter) {
632 if (iter->value == -100) {
633 g_suspending = true;
634 while (g_suspending) {
635 usleep(10);
636 }
637 if (iter->event) { iter->event->signal(); }
638 } else {
639 *result += iter->value;
640 if (iter->event) { iter->event->signal(); }
641 }
642 }
643 return 0;
644}
645
646void test_cancel(bool use_pthread) {
647 bthread::ExecutionQueueId<LongIntTask> queue_id = { 0 }; // to suppress warnings

Callers

nothing calls this directly

Calls 2

is_queue_stoppedMethod · 0.80
signalMethod · 0.80

Tested by

no test coverage detected