void c_AsyncFunctionWaitHandle::initialize(c_WaitableWaitHandle* child) { setState(STATE_BLOCKED); m_child = child; m_privData = nullptr; blockOn(child); // needs to be called with non-zero refcnt auto session = AsioSession::Get(); if (UNLIKELY(session->hasOnAsyncFunctionCreateCallback())) { session->onAsyncFunctionCreate(this, child); } }
void EventHook::onFunctionSuspend(const ActRec* ar, bool suspendingResumed) { ssize_t flags = CheckSurprise(); onFunctionExit(ar, nullptr, nullptr, flags); // Async profiler if ((flags & RequestInjectionData::AsyncEventHookFlag) && ar->func()->isAsyncFunction()) { assert(ar->resumed()); auto afwh = frame_afwh(ar); auto session = AsioSession::Get(); // Blocking await @ eager execution => AsyncFunctionWaitHandle created. if (!suspendingResumed && session->hasOnAsyncFunctionCreateCallback()) { session->onAsyncFunctionCreate(afwh, afwh->getChild()); } // Blocking await @ resumed execution => AsyncFunctionWaitHandle awaiting. if (suspendingResumed && session->hasOnAsyncFunctionAwaitCallback()) { session->onAsyncFunctionAwait(afwh, afwh->getChild()); } } }