| 76 | } |
| 77 | |
| 78 | void 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 | |
| 114 | void fiber_pool::running(task_box<task_fn>* box) |
| 115 | { |
nothing calls this directly
no test coverage detected