c_AsyncFunctionWaitHandle* c_AsyncFunctionWaitHandle::Create(const ActRec* fp, size_t numSlots, JIT::TCA resumeAddr, Offset resumeOffset, ObjectData* child) { assert(fp); assert(!fp->resumed()); assert(fp->func()->isAsyncFunction()); assert(child); assert(child->instanceof(c_WaitableWaitHandle::classof())); auto child_wh = static_cast<c_WaitableWaitHandle*>(child); assert(!child_wh->isFinished()); checkCreateErrors(child_wh); void* obj = Resumable::Create(fp, numSlots, resumeAddr, resumeOffset, sizeof(c_AsyncFunctionWaitHandle)); auto const waitHandle = new (obj) c_AsyncFunctionWaitHandle(); waitHandle->incRefCount(); waitHandle->setNoDestruct(); waitHandle->initialize(child_wh); return waitHandle; }
c_AsyncGenerator* c_AsyncGenerator::Create(const ActRec* fp, size_t numSlots, jit::TCA resumeAddr, Offset resumeOffset) { assert(fp); assert(!fp->resumed()); assert(fp->func()->isAsyncGenerator()); void* obj = Resumable::Create<false>(fp, numSlots, resumeAddr, resumeOffset, sizeof(c_AsyncGenerator)); auto const gen = new (obj) c_AsyncGenerator(); gen->incRefCount(); gen->setNoDestruct(); gen->setState(State::Created); gen->m_waitHandle = nullptr; return gen; }