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

Function add_with_cancel

test/bthread_execution_queue_unittest.cpp:740–761  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

738};
739
740int add_with_cancel(void* meta, bthread::TaskIterator<AddTask>& iter) {
741 if (iter.is_queue_stopped()) {
742 return 0;
743 }
744 AddMeta* m = (AddMeta*)meta;
745 for (; iter; ++iter) {
746 if (iter->cancel_task) {
747 const int rc = bthread::execution_queue_cancel(iter->handle);
748 if (rc == 0) {
749 m->expected.fetch_sub(iter->cancel_value);
750 m->succ_times.fetch_add(1);
751 } else if (rc < 0) {
752 m->fail_times.fetch_add(1);
753 } else {
754 m->race_times.fetch_add(1);
755 }
756 } else {
757 m->sum += iter->value;
758 }
759 }
760 return 0;
761}
762
763void test_random_cancel(bool use_pthread) {
764 bthread::ExecutionQueueId<AddTask> queue_id = { 0 };

Callers

nothing calls this directly

Calls 4

execution_queue_cancelFunction · 0.85
is_queue_stoppedMethod · 0.80
fetch_subMethod · 0.80
fetch_addMethod · 0.80

Tested by

no test coverage detected