本文整理汇总了C++中setContextIdx函数的典型用法代码示例。如果您正苦于以下问题:C++ setContextIdx函数的具体用法?C++ setContextIdx怎么用?C++ setContextIdx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setContextIdx函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: switch
void c_AsyncGeneratorWaitHandle::enterContextImpl(context_idx_t ctx_idx) {
switch (getState()) {
case STATE_BLOCKED:
// enter child into new context recursively
assert(m_child);
m_child->enterContext(ctx_idx);
setContextIdx(ctx_idx);
break;
case STATE_SCHEDULED:
// reschedule so that we get run
setContextIdx(ctx_idx);
getContext()->schedule(this);
incRefCount();
break;
case STATE_RUNNING: {
Object e(SystemLib::AllocInvalidOperationExceptionObject(
"Detected cross-context dependency cycle. You are trying to depend "
"on something that is running you serially."));
throw e;
}
default:
assert(false);
}
}
开发者ID:AojiaoZero,项目名称:hhvm,代码行数:27,代码来源:async_generator_wait_handle.cpp
示例2: assert
void c_RescheduleWaitHandle::exitContext(context_idx_t ctx_idx) {
assert(AsioSession::Get()->getContext(ctx_idx));
// stop before corrupting unioned data
if (isFinished()) {
return;
}
// not in a context being exited
assert(getContextIdx() <= ctx_idx);
if (getContextIdx() != ctx_idx) {
return;
}
if (UNLIKELY(getState() != STATE_SCHEDULED)) {
raise_fatal_error("Invariant violation: encountered unexpected state");
}
// move us to the parent context
setContextIdx(getContextIdx() - 1);
// reschedule if still in a context
if (isInContext()) {
scheduleInContext();
}
// recursively move all wait handles blocked by us
getParentChain().exitContext(ctx_idx);
}
开发者ID:DerPapst,项目名称:hhvm,代码行数:29,代码来源:ext_reschedule-wait-handle.cpp
示例3: assert
void c_RescheduleWaitHandle::exitContext(context_idx_t ctx_idx) {
assert(AsioSession::Get()->getContext(ctx_idx));
// stop before corrupting unioned data
if (isFinished()) {
return;
}
// not in a context being exited
assert(getContextIdx() <= ctx_idx);
if (getContextIdx() != ctx_idx) {
return;
}
if (UNLIKELY(getState() != STATE_SCHEDULED)) {
throw FatalErrorException(
"Invariant violation: encountered unexpected state");
}
// move us to the parent context
setContextIdx(getContextIdx() - 1);
// reschedule if still in a context
if (isInContext()) {
getContext()->schedule(this, m_queue, m_priority);
}
// recursively move all wait handles blocked by us
for (auto pwh = getFirstParent(); pwh; pwh = pwh->getNextParent()) {
pwh->exitContextBlocked(ctx_idx);
}
}
开发者ID:360buyliulei,项目名称:hiphop-php,代码行数:32,代码来源:reschedule_wait_handle.cpp
示例4: assert
void c_AwaitAllWaitHandle::enterContextImpl(context_idx_t ctx_idx) {
assert(getState() == STATE_BLOCKED);
assert(m_cur >= 0);
// recursively import current child
m_children[m_cur]->enterContext(ctx_idx);
// import ourselves
setContextIdx(ctx_idx);
// try to import other children
auto cur = m_cur;
auto child = &m_children[cur];
while (cur > 0) {
--cur;
--child;
if ((*child)->isFinished()) {
continue;
}
try {
(*child)->enterContext(ctx_idx);
} catch (const Object& cycle_exception) {
// exception will be eventually processed by onUnblocked()
}
}
}
开发者ID:bjori,项目名称:hhvm,代码行数:29,代码来源:await_all_wait_handle.cpp
示例5: assert
void c_GenArrayWaitHandle::enterContext(context_idx_t ctx_idx) {
assert(AsioSession::Get()->getContext(ctx_idx));
// stop before corrupting unioned data
if (isFinished()) {
return;
}
// already in the more specific context?
if (LIKELY(getContextIdx() >= ctx_idx)) {
return;
}
assert(getState() == STATE_BLOCKED);
// recursively import current child
{
assert(m_iterPos != ArrayData::invalid_index);
TypedValue* current = m_deps->nvGetValueRef(m_iterPos);
assert(current->m_type == KindOfObject);
assert(dynamic_cast<c_WaitableWaitHandle*>(current->m_data.pobj));
auto child_wh = static_cast<c_WaitableWaitHandle*>(current->m_data.pobj);
child_wh->enterContext(ctx_idx);
}
// import ourselves
setContextIdx(ctx_idx);
// try to import other children
try {
for (ssize_t iter_pos = m_deps->iter_advance(m_iterPos);
iter_pos != ArrayData::invalid_index;
iter_pos = m_deps->iter_advance(iter_pos)) {
TypedValue* current = m_deps->nvGetValueRef(iter_pos);
if (IS_NULL_TYPE(current->m_type)) {
continue;
}
assert(current->m_type == KindOfObject);
assert(dynamic_cast<c_WaitHandle*>(current->m_data.pobj));
auto child = static_cast<c_WaitHandle*>(current->m_data.pobj);
if (child->isFinished()) {
continue;
}
assert(dynamic_cast<c_WaitableWaitHandle*>(child));
auto child_wh = static_cast<c_WaitableWaitHandle*>(child);
child_wh->enterContext(ctx_idx);
}
} catch (const Object& cycle_exception) {
// exception will be eventually processed by onUnblocked()
}
}
开发者ID:MarkTseng,项目名称:hiphop-php,代码行数:56,代码来源:gen_array_wait_handle.cpp
示例6: assert
void c_ExternalThreadEventWaitHandle::enterContextImpl(context_idx_t ctx_idx) {
assert(getState() == STATE_WAITING);
if (isInContext()) {
unregisterFromContext();
}
setContextIdx(ctx_idx);
registerToContext();
}
开发者ID:6api,项目名称:hhvm,代码行数:10,代码来源:external_thread_event_wait_handle.cpp
示例7: assert
void c_SessionScopedWaitHandle::enterContextImpl(context_idx_t ctx_idx) {
assert(getState() == STATE_WAITING);
if (isInContext()) {
unregisterFromContext();
}
setContextIdx(ctx_idx);
registerToContext();
}
开发者ID:Alienfeel,项目名称:hhvm,代码行数:10,代码来源:session_scoped_wait_handle.cpp
示例8: setState
void c_RescheduleWaitHandle::initialize(uint32_t queue, int64_t priority) {
setState(STATE_SCHEDULED);
setContextIdx(AsioSession::Get()->getCurrentContextIdx());
m_queue = queue;
m_priority = priority;
if (isInContext()) {
scheduleInContext();
}
}
开发者ID:DerPapst,项目名称:hhvm,代码行数:10,代码来源:ext_reschedule-wait-handle.cpp
示例9: setState
void c_AsyncGeneratorWaitHandle::initialize(AsyncGenerator* gen,
c_WaitableWaitHandle* child) {
setState(STATE_BLOCKED);
setContextIdx(child->getContextIdx());
m_generator = gen;
m_generator->toObject()->incRefCount();
m_child = child;
m_child->getParentChain()
.addParent(m_blockable, AsioBlockable::Kind::AsyncGeneratorWaitHandle);
incRefCount();
}
开发者ID:stone54321277,项目名称:hhvm,代码行数:11,代码来源:ext_async-generator-wait-handle.cpp
示例10: setState
void c_GenMapWaitHandle::initialize(const Object& exception, c_Map* deps, ssize_t iter_pos, c_WaitableWaitHandle* child) {
setState(STATE_BLOCKED);
setContextIdx(child->getContextIdx());
m_exception = exception;
m_deps = deps;
m_iterPos = iter_pos;
child->getParentChain()
.addParent(m_blockable, AsioBlockable::Kind::GenMapWaitHandle);
incRefCount();
}
开发者ID:hardfight,项目名称:hhvm,代码行数:11,代码来源:gen_map_wait_handle.cpp
示例11: c_WaitHandle
c_WaitableWaitHandle::c_WaitableWaitHandle(Class* cb)
: c_WaitHandle(cb)
, m_creator(AsioSession::Get()->getCurrentWaitHandle())
, m_firstParent(nullptr) {
setState(STATE_NEW);
setContextIdx(AsioSession::Get()->getCurrentContextIdx());
// ref creator
if (m_creator) {
m_creator->incRefCount();
}
}
开发者ID:HendrikGrunstra,项目名称:hiphop-php,代码行数:12,代码来源:waitable_wait_handle.cpp
示例12: assert
void c_GenVectorWaitHandle::enterContext(context_idx_t ctx_idx) {
assert(AsioSession::Get()->getContext(ctx_idx));
// stop before corrupting unioned data
if (isFinished()) {
return;
}
// already in the more specific context?
if (LIKELY(getContextIdx() >= ctx_idx)) {
return;
}
assert(getState() == STATE_BLOCKED);
// recursively import current child
{
assert(m_iterPos < m_deps->size());
Cell* current = tvAssertCell(m_deps->at(m_iterPos));
assert(current->m_type == KindOfObject);
assert(dynamic_cast<c_WaitableWaitHandle*>(current->m_data.pobj));
auto child_wh = static_cast<c_WaitableWaitHandle*>(current->m_data.pobj);
child_wh->enterContext(ctx_idx);
}
// import ourselves
setContextIdx(ctx_idx);
// try to import other children
try {
for (int64_t iter_pos = m_iterPos + 1;
iter_pos < m_deps->size();
++iter_pos) {
Cell* current = tvAssertCell(m_deps->at(iter_pos));
assert(current->m_type == KindOfObject);
assert(dynamic_cast<c_WaitHandle*>(current->m_data.pobj));
auto child = static_cast<c_WaitHandle*>(current->m_data.pobj);
if (child->isFinished()) {
continue;
}
assert(dynamic_cast<c_WaitableWaitHandle*>(child));
auto child_wh = static_cast<c_WaitableWaitHandle*>(child);
child_wh->enterContext(ctx_idx);
}
} catch (const Object& cycle_exception) {
// exception will be eventually processed by onUnblocked()
}
}
开发者ID:HendrikGrunstra,项目名称:hiphop-php,代码行数:52,代码来源:gen_vector_wait_handle.cpp
示例13: assert
void c_ContinuationWaitHandle::enterContext(context_idx_t ctx_idx) {
assert(AsioSession::Get()->getContext(ctx_idx));
// stop before corrupting unioned data
if (isFinished()) {
return;
}
// already in the more specific context?
if (LIKELY(getContextIdx() >= ctx_idx)) {
return;
}
switch (getState()) {
case STATE_BLOCKED:
// enter child into new context recursively
assert(dynamic_cast<c_WaitableWaitHandle*>(m_child.get()));
static_cast<c_WaitableWaitHandle*>(m_child.get())->enterContext(ctx_idx);
setContextIdx(ctx_idx);
break;
case STATE_SCHEDULED:
// reschedule so that we get run
setContextIdx(ctx_idx);
getContext()->schedule(this);
break;
case STATE_RUNNING: {
Object e(SystemLib::AllocInvalidOperationExceptionObject(
"Detected cross-context dependency cycle. You are trying to depend "
"on something that is running you serially."));
throw e;
}
default:
assert(false);
}
}
开发者ID:gilshwartz,项目名称:hiphop-php,代码行数:38,代码来源:continuation_wait_handle.cpp
示例14: setState
void c_AwaitAllWaitHandle::initialize(context_idx_t ctx_idx) {
setState(STATE_BLOCKED);
setContextIdx(ctx_idx);
if (UNLIKELY(AsioSession::Get()->hasOnAwaitAllCreate())) {
auto vector = req::make<c_Vector>();
for (int32_t idx = m_cap - 1; idx >= 0; --idx) {
TypedValue child = make_tv<KindOfObject>(m_children[idx].m_child);
vector->add(&child);
}
AsioSession::Get()->onAwaitAllCreate(this, Variant(std::move(vector)));
}
incRefCount();
}
开发者ID:StetHD,项目名称:hhvm,代码行数:15,代码来源:ext_await-all-wait-handle.cpp
示例15: assert
void c_SleepWaitHandle::exitContext(context_idx_t ctx_idx) {
assert(AsioSession::Get()->getContext(ctx_idx));
assert(getState() == STATE_WAITING);
assert(getContextIdx() == ctx_idx);
// Move us to the parent context.
setContextIdx(getContextIdx() - 1);
// Re-register if still in a context.
if (isInContext()) {
registerToContext();
}
// Recursively move all wait handles blocked by us.
getParentChain().exitContext(ctx_idx);
}
开发者ID:191919,项目名称:hhvm,代码行数:16,代码来源:sleep-wait-handle.cpp
示例16: assert
void c_BlockableWaitHandle::exitContextBlocked(context_idx_t ctx_idx) {
assert(getState() == STATE_BLOCKED);
assert(AsioSession::Get()->getContext(ctx_idx));
// not in a context being exited
assert(getContextIdx() <= ctx_idx);
if (getContextIdx() != ctx_idx) {
return;
}
// move us to the parent context
setContextIdx(getContextIdx() - 1);
// recursively move all wait handles blocked by us
getParentChain().exitContext(ctx_idx);
}
开发者ID:AmineCherrai,项目名称:hhvm,代码行数:16,代码来源:blockable_wait_handle.cpp
示例17: assert
void c_ConditionWaitHandle::initialize(c_WaitableWaitHandle* child) {
assert(!child->isFinished());
setState(STATE_BLOCKED);
setContextIdx(child->getContextIdx());
m_child = child;
m_child->incRefCount();
m_child->getParentChain()
.addParent(m_blockable, AsioBlockable::Kind::ConditionWaitHandle);
incRefCount();
auto const session = AsioSession::Get();
if (UNLIKELY(session->hasOnConditionCreate())) {
session->onConditionCreate(this, child);
}
}
开发者ID:shixiao,项目名称:hhvm,代码行数:16,代码来源:ext_condition-wait-handle.cpp
示例18: assert
void c_AsyncFunctionWaitHandle::exitContext(context_idx_t ctx_idx) {
assert(AsioSession::Get()->getContext(ctx_idx));
// stop before corrupting unioned data
if (isFinished()) {
decRefObj(this);
return;
}
// not in a context being exited
assert(getContextIdx() <= ctx_idx);
if (getContextIdx() != ctx_idx) {
decRefObj(this);
return;
}
switch (getState()) {
case STATE_BLOCKED:
// we were already ran due to duplicit scheduling; the context will be
// updated thru exitContext() call on the non-blocked wait handle we
// recursively depend on
decRefObj(this);
break;
case STATE_READY:
// Recursively move all wait handles blocked by us.
getParentChain().exitContext(ctx_idx);
// Move us to the parent context.
setContextIdx(getContextIdx() - 1);
// Reschedule if still in a context.
if (isInContext()) {
if (isFastResumable()) {
getContext()->scheduleFast(this);
} else {
getContext()->schedule(this);
}
} else {
decRefObj(this);
}
break;
default:
assert(false);
}
}
开发者ID:Openplaystation4,项目名称:hhvm,代码行数:47,代码来源:ext_async-function-wait-handle.cpp
示例19: setState
void c_GenVectorWaitHandle::initialize(
const Object& exception,
c_Vector* deps,
int64_t iter_pos,
context_idx_t ctx_idx,
c_WaitableWaitHandle* child
) {
setState(STATE_BLOCKED);
setContextIdx(ctx_idx);
m_exception = exception;
m_deps = deps;
m_iterPos = iter_pos;
child->getParentChain()
.addParent(m_blockable, AsioBlockable::Kind::GenVectorWaitHandle);
incRefCount();
}
开发者ID:RavenB,项目名称:hhvm,代码行数:17,代码来源:ext_gen-vector-wait-handle.cpp
示例20: setState
void c_AwaitAllWaitHandle::initialize(context_idx_t ctx_idx) {
setState(STATE_BLOCKED);
setContextIdx(ctx_idx);
assert(m_cur >= 0);
if (UNLIKELY(AsioSession::Get()->hasOnAwaitAllCreateCallback())) {
auto vector = makeSmartPtr<c_Vector>();
for (int32_t idx = m_cur; idx >= 0; --idx) {
TypedValue child = make_tv<KindOfObject>(m_children[idx]);
vector->add(&child);
}
AsioSession::Get()->onAwaitAllCreate(this, Variant(std::move(vector)));
}
blockOnCurrent<false>();
incRefCount();
}
开发者ID:AmritanshuRanjan,项目名称:hhvm,代码行数:17,代码来源:await-all-wait-handle.cpp
注:本文中的setContextIdx函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论