fiber* create_fiber(Fn &&fn, Args&&... args) { lock_guard<shared_timed_mutex> guard(m_); std::unique_ptr<fiber> new_fiber(new fiber(std::forward<Fn>(fn), std::forward<Args>(args)...)); fibers_.push_back(new_fiber.get()); return new_fiber.release(); }
god_error_t god_fiber_create(god_fiber_ptr *fiber, god_fiber_entry_t entry, god_intptr_t param) { god_fiber_scheduler_ptr cur_scheduler = g_scheduler; assert(cur_scheduler != god_invalid_fiber_scheduler); if (god_unlikely(cur_scheduler == god_invalid_fiber_scheduler)) { return -1; //TODO:NOFIBERSCHED; } god_fiber_ptr f = new_fiber(k_stack_size, entry, param); if (god_unlikely(f == god_invalid_fiber)) { return ENOMEM; } #ifndef _GOD_NDEBUG_ f->scheduler = cur_scheduler; #endif //god_list_push_back(&cur_scheduler->all_list, &f->all_node); god_list_push_back(&cur_scheduler->list, &f->node); if (god_unlikely(fiber != nil)) { *fiber = f; } return EOK; }