Ejemplo n.º 1
0
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_AsyncGeneratorWaitHandle*
c_AsyncGeneratorWaitHandle::Create(c_AsyncGenerator* gen,
                                   c_WaitableWaitHandle* child) {
  assert(child);
  assert(child->instanceof(c_WaitableWaitHandle::classof()));
  assert(!child->isFinished());

  checkCreateErrors(child);
  auto const waitHandle = NEWOBJ(c_AsyncGeneratorWaitHandle)();
  waitHandle->incRefCount();
  waitHandle->initialize(gen, child);
  return waitHandle;
}