当前位置: 首页>>代码示例>>C++>>正文


C++ AsioSession::isInContext方法代码示例

本文整理汇总了C++中AsioSession::isInContext方法的典型用法代码示例。如果您正苦于以下问题:C++ AsioSession::isInContext方法的具体用法?C++ AsioSession::isInContext怎么用?C++ AsioSession::isInContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AsioSession的用法示例。


在下文中一共展示了AsioSession::isInContext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: join

// throws on context depth level overflows and cross-context cycles
void c_WaitableWaitHandle::join() {
  JIT::EagerVMRegAnchor _;

  AsioSession* session = AsioSession::Get();

  assert(!isFinished());
  assert(!session->isInContext() || session->getCurrentContext()->isRunning());

  if (UNLIKELY(session->hasOnJoinCallback())) {
    session->onJoin(this);
  }

  // enter new asio context and set up guard that will exit once we are done
  session->enterContext();
  auto exit_guard = folly::makeGuard([&] { session->exitContext(); });

  assert(session->isInContext());
  assert(!session->getCurrentContext()->isRunning());

  // import this wait handle to the newly created context
  // throws if cross-context cycle found
  enterContext(session->getCurrentContextIdx());

  // run queues until we are finished
  session->getCurrentContext()->runUntil(this);
  assert(isFinished());
}
开发者ID:NIT-Warangal,项目名称:Judge,代码行数:28,代码来源:waitable_wait_handle.cpp

示例2: join

// throws on context depth level overflows and cross-context cycles
void c_WaitableWaitHandle::join() {
    AsioSession* session = AsioSession::Get();

    assert(!isFinished());
    assert(!session->isInContext() || session->getCurrentContext()->isRunning());

    if (UNLIKELY(session->hasOnJoinCallback())) {
        session->onJoin(this);
    }

    // enter new asio context and set up guard that will exit once we are done
    session->enterContext();

    assert(session->isInContext());
    assert(!session->getCurrentContext()->isRunning());

    try {
        // import this wait handle to the newly created context
        // throws if cross-context cycle found
        enterContext(session->getCurrentContextIdx());

        // run queues until we are finished
        session->getCurrentContext()->runUntil(this);
    } catch (const Object& exception) {
        // recover from PHP exceptions; HPHP internal exceptions are deliberately
        // ignored as there is no easy way to recover from them
        session->exitContext();
        throw;
    }
    session->exitContext();

    assert(isFinished());
}
开发者ID:CyaLiven,项目名称:hiphop-php,代码行数:34,代码来源:waitable_wait_handle.cpp

示例3: Create

void c_AsyncFunctionWaitHandle::Create(c_Continuation* continuation) {
  assert(continuation);
  assert(continuation->m_label > 0);
  assert(continuation->m_waitHandle.isNull());

  AsioSession* session = AsioSession::Get();
  uint16_t depth = session->getCurrentWaitHandleDepth();
  if (UNLIKELY(depth >= MAX_DEPTH)) {
    Object e(SystemLib::AllocInvalidOperationExceptionObject(
        "Asio stack overflow"));
    throw e;
  }

  Cell* value = tvAssertCell(continuation->m_value.asTypedValue());
  assert(dynamic_cast<c_WaitableWaitHandle*>(c_WaitHandle::fromCell(value)));
  auto child = static_cast<c_WaitableWaitHandle*>(value->m_data.pobj);
  assert(!child->isFinished());

  // import child into the current context, detect cross-context cycles
  if (session->isInContext()) {
    child->enterContext(session->getCurrentContextIdx());
  }

  continuation->m_waitHandle = NEWOBJ(c_AsyncFunctionWaitHandle)();
  continuation->m_waitHandle->initialize(continuation, child, depth + 1);

  // needs to be called after continuation->m_waitHandle is set
  if (UNLIKELY(session->hasOnAsyncFunctionCreateCallback())) {
    session->onAsyncFunctionCreate(continuation->m_waitHandle.get());
  }
}
开发者ID:nkhuyu,项目名称:hhvm,代码行数:31,代码来源:async_function_wait_handle.cpp

示例4: ti_start

Object c_ContinuationWaitHandle::ti_start(const char* cls, CObjRef continuation) {
  AsioSession* session = AsioSession::Get();
  if (UNLIKELY(!continuation.instanceof(SystemLib::s_ContinuationClass))) {
    Object e(SystemLib::AllocInvalidArgumentExceptionObject(
        "Expected continuation to be an instance of Continuation"));
    throw e;
  }

  uint16_t depth = session->getCurrentWaitHandleDepth();
  if (UNLIKELY(depth >= MAX_DEPTH)) {
    Object e(SystemLib::AllocInvalidOperationExceptionObject(
        "Asio stack overflow"));
    throw e;
  }

  c_Continuation* cont = static_cast<c_Continuation*>(continuation.get());
  if (!cont->m_waitHandle.isNull()) {
    if (session->isInContext()) {
      // throws if cross-context cycle found
      cont->m_waitHandle->enterContext(session->getCurrentContextIdx());
    }
    return cont->m_waitHandle;
  }

  if (UNLIKELY(cont->m_index != -1)) {
    assert(cont->m_running);
    Object e(SystemLib::AllocInvalidOperationExceptionObject(
        "Encountered an attempt to start currently running continuation"));
    throw e;
  }

  p_ContinuationWaitHandle wh = NEWOBJ(c_ContinuationWaitHandle)();
  wh->start(cont, depth + 1);
  if (UNLIKELY(session->hasOnStartedCallback())) {
    session->onStarted(wh);
  }
  return wh;
}
开发者ID:ChrisOHu,项目名称:hiphop-php,代码行数:38,代码来源:continuation_wait_handle.cpp


注:本文中的AsioSession::isInContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。