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

Method running

lib_fiber/cpp/src/fiber_pool.cpp:114–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114void fiber_pool::running(task_box<task_fn>* box)
115{
116 while (true) {
117 task_fn t;
118
119 if (!box->box->pop(t, idle_ms_)) {
120 if (fiber::self_killed()) {
121 break;
122 } else if (last_error() == EAGAIN) {
123 if (box_count_ > box_min_) {
124 break;
125 }
126 continue;
127 }
128 }
129
130 assert(box->idle >= 0);
131
132 if (box_idle_-- > 1) {
133 if (box->idle < box_idle_) {
134 boxes_idle_[box->idle] = boxes_idle_[box_idle_];
135 boxes_idle_[box->idle]->idle = box->idle;
136 }
137 boxes_idle_[box_idle_] = nullptr;
138 } else {
139 assert(box_idle_ == 0);
140 assert(boxes_idle_[0] == box);
141 boxes_idle_[0] = nullptr;
142 }
143
144 box->idle = -1;
145
146 if (box_idle_ == 0 && box_count_ < box_max_) {
147 fiber_create(1);
148 }
149
150 t();
151
152 assert(box_idle_ < (ssize_t) box_count_);
153
154 box->idle = box_idle_;
155 boxes_idle_[box_idle_++] = box;
156 }
157}
158
159} // namespace acl
160

Callers

nothing calls this directly

Calls 3

last_errorFunction · 0.85
tFunction · 0.50
popMethod · 0.45

Tested by

no test coverage detected