Пример #1
0
void AsioBlockableChain::unblock() {
  auto cur = m_firstParent;
  while (cur) {
    auto const next = cur->getNextParent();

    // May free cur.
    switch (cur->getKind()) {
      case Kind::AsyncFunctionWaitHandleNode:
        getAsyncFunctionWaitHandleNode(cur)->onUnblocked();
        break;
      case Kind::AsyncGeneratorWaitHandle:
        getAsyncGeneratorWaitHandle(cur)->onUnblocked();
        break;
      case Kind::AwaitAllWaitHandle:
        getAwaitAllWaitHandle(cur)->onUnblocked();
        break;
      case Kind::ConditionWaitHandle:
        getConditionWaitHandle(cur)->onUnblocked();
        break;
      case Kind::GenArrayWaitHandle:
        getGenArrayWaitHandle(cur)->onUnblocked();
        break;
      case Kind::GenMapWaitHandle:
        getGenMapWaitHandle(cur)->onUnblocked();
        break;
      case Kind::GenVectorWaitHandle:
        getGenVectorWaitHandle(cur)->onUnblocked();
        break;
    }

    cur = next;
  }
}
Пример #2
0
void AsioBlockableChain::exitContext(context_idx_t ctx_idx) {
  for (auto cur = m_firstParent; cur; cur = cur->getNextParent()) {
    switch (cur->getKind()) {
      case Kind::AsyncFunctionWaitHandleNode:
        exitContextImpl(getAsyncFunctionWaitHandleNode(cur), ctx_idx);
        break;
      case Kind::AsyncGeneratorWaitHandle:
        exitContextImpl(getAsyncGeneratorWaitHandle(cur), ctx_idx);
        break;
      case Kind::AwaitAllWaitHandle:
        exitContextImpl(getAwaitAllWaitHandle(cur), ctx_idx);
        break;
      case Kind::ConditionWaitHandle:
        exitContextImpl(getConditionWaitHandle(cur), ctx_idx);
        break;
      case Kind::GenArrayWaitHandle:
        exitContextImpl(getGenArrayWaitHandle(cur), ctx_idx);
        break;
      case Kind::GenMapWaitHandle:
        exitContextImpl(getGenMapWaitHandle(cur), ctx_idx);
        break;
      case Kind::GenVectorWaitHandle:
        exitContextImpl(getGenVectorWaitHandle(cur), ctx_idx);
        break;
    }
  }
}
Пример #3
0
void AsioBlockableChain::unblock() {
  for (AsioBlockable* cur = m_firstParent, *next; cur; cur = next) {
    next = cur->getNextParent();
    // the onUnblocked handler may free cur
    switch (cur->getKind()) {
      case Kind::AsyncFunctionWaitHandleNode:
        getAsyncFunctionWaitHandleNode(cur)->onUnblocked();
        break;
      case Kind::AsyncGeneratorWaitHandle:
        getAsyncGeneratorWaitHandle(cur)->onUnblocked();
        break;
      case Kind::AwaitAllWaitHandle:
        getAwaitAllWaitHandle(cur)->onUnblocked();
        break;
      case Kind::ConditionWaitHandle:
        getConditionWaitHandle(cur)->onUnblocked();
        break;
      case Kind::GenArrayWaitHandle:
        getGenArrayWaitHandle(cur)->onUnblocked();
        break;
      case Kind::GenMapWaitHandle:
        getGenMapWaitHandle(cur)->onUnblocked();
        break;
      case Kind::GenVectorWaitHandle:
        getGenVectorWaitHandle(cur)->onUnblocked();
        break;
    }
  }
}
Пример #4
0
void AsioBlockableChain::exitContext(context_idx_t ctx_idx) {
  for (auto cur = m_firstParent; cur; cur = cur->getNextParent()) {
    switch (cur->getKind()) {
      case AsioBlockable::Kind::BlockableWaitHandle:
        cur->getBlockableWaitHandle()->exitContextBlocked(ctx_idx);
        break;
      case AsioBlockable::Kind::ConditionWaitHandle:
        cur->getConditionWaitHandle()->exitContextBlocked(ctx_idx);
        break;
    }
  }
}
Пример #5
0
Array AsioBlockableChain::toArray() {
  Array result = Array::Create();

  for (auto cur = m_firstParent; cur; cur = cur->getNextParent()) {
    switch (cur->getKind()) {
      case AsioBlockable::Kind::BlockableWaitHandle:
        result.append(cur->getBlockableWaitHandle());
        break;
      case AsioBlockable::Kind::ConditionWaitHandle:
        result.append(cur->getConditionWaitHandle());
        break;
    }
  }

  return result;
}
Пример #6
0
void AsioBlockableChain::unblock() {
  auto cur = m_firstParent;
  while (cur) {
    auto const next = cur->getNextParent();

    // May free cur.
    switch (cur->getKind()) {
      case AsioBlockable::Kind::BlockableWaitHandle:
        dispatchUnblock(cur->getBlockableWaitHandle());
        break;
      case AsioBlockable::Kind::ConditionWaitHandle:
        cur->getConditionWaitHandle()->onUnblocked();
        break;
    }

    cur = next;
  }
}
Пример #7
0
c_WaitableWaitHandle* AsioBlockable::getWaitHandle() const {
  switch (getKind()) {
    case Kind::AsyncFunctionWaitHandleNode:
      return getAsyncFunctionWaitHandleNode(this)->getWaitHandle();
    case Kind::AsyncGeneratorWaitHandle:
      return getAsyncGeneratorWaitHandle(this);
    case Kind::AwaitAllWaitHandle:
      return getAwaitAllWaitHandle(this);
    case Kind::ConditionWaitHandle:
      return getConditionWaitHandle(this);
    case Kind::GenArrayWaitHandle:
      return getGenArrayWaitHandle(this);
    case Kind::GenMapWaitHandle:
      return getGenMapWaitHandle(this);
    case Kind::GenVectorWaitHandle:
      return getGenVectorWaitHandle(this);
  }
  not_reached();
}