MCPcopy Create free account
hub / github.com/acl-dev/acl / fiber_run

Method fiber_run

lib_fiber/cpp/src/fiber_pool.cpp:78–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78void fiber_pool::fiber_run(task_box<task_fn>* box)
79{
80 boxes_idle_[box_idle_] = box;
81 box->idle = box_idle_++;
82
83 std::shared_ptr<fiber> fb(new fiber(acl_fiber_running()));
84 box->fb = fb;
85 fibers_.insert(fb);
86
87 running(box);
88
89 if (box_count_-- > 1) {
90 boxes_[box->idx] = boxes_[box_count_];
91 boxes_[box->idx]->idx = box->idx;
92 boxes_[box_count_] = nullptr;
93 } else {
94 assert(box_count_ == 0);
95 boxes_[box_count_] = nullptr;
96 }
97
98 if (box->idle >= 0) {
99 if (box_idle_-- > 1) {
100 boxes_idle_[box->idle] = boxes_idle_[box_idle_];
101 boxes_idle_[box->idle]->idle = box->idle;
102 boxes_idle_[box_idle_] = nullptr;
103 } else {
104 assert(box_idle_ == 0);
105 assert(boxes_idle_[0] == box);
106 boxes_idle_[0] = nullptr;
107 }
108 }
109
110 fibers_.erase(box->fb);
111 wg_->done();
112}
113
114void fiber_pool::running(task_box<task_fn>* box)
115{

Callers

nothing calls this directly

Calls 3

insertMethod · 0.80
acl_fiber_runningFunction · 0.50
doneMethod · 0.45

Tested by

no test coverage detected