MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / defer_to_new_thread

Method defer_to_new_thread

thread/thread.cpp:704–719  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

702 th->remove_from_list();
703 }
704 bool defer_to_new_thread() const {
705 auto idle_worker = vcpu->idle_worker;
706 if (current->next() == idle_worker) {
707 if (idle_worker->next() == current) {
708 // if defer_func is executed in idle_worker and it yields,
709 // photon will be broken. so we should return true and
710 // create a new thread to execute the defer func.
711 return true;
712 }
713
714 // postpone idle worker
715 auto next = idle_worker->remove_from_list();
716 next->insert_after(idle_worker);
717 }
718 return false;
719 }
720 };
721
722 inline void thread::dequeue_ready_atomic(states newstat)

Callers 1

thread_usleep_deferFunction · 0.80

Calls 3

nextMethod · 0.45
remove_from_listMethod · 0.45
insert_afterMethod · 0.45

Tested by

no test coverage detected