| 52 | } |
| 53 | |
| 54 | void fiber_pool::fiber_create(size_t count) |
| 55 | { |
| 56 | for (size_t i = 0; i < count; i++) { |
| 57 | wg_->add(1); |
| 58 | |
| 59 | auto* box2 = new fiber_sbox2<task_fn>(box_buf_); |
| 60 | auto* box = new task_box<task_fn>(box2); |
| 61 | boxes_[box_count_] = box; |
| 62 | box->idx = (int) box_count_++; |
| 63 | |
| 64 | if (stack_share_) { |
| 65 | go_share(stack_size_)[this, box] { |
| 66 | fiber_run(box); |
| 67 | delete box; |
| 68 | }; |
| 69 | } else { |
| 70 | go_stack(stack_size_)[this, box] { |
| 71 | fiber_run(box); |
| 72 | delete box; |
| 73 | }; |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | void fiber_pool::fiber_run(task_box<task_fn>* box) |
| 79 | { |