本文整理汇总了C++中AsioSession::hasOnGenVectorCreate方法的典型用法代码示例。如果您正苦于以下问题:C++ AsioSession::hasOnGenVectorCreate方法的具体用法?C++ AsioSession::hasOnGenVectorCreate怎么用?C++ AsioSession::hasOnGenVectorCreate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AsioSession
的用法示例。
在下文中一共展示了AsioSession::hasOnGenVectorCreate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ti_create
Object c_GenVectorWaitHandle::ti_create(const Variant& dependencies) {
ObjectData* obj;
if (UNLIKELY(!dependencies.isObject() ||
!(obj = dependencies.getObjectData())->isCollection() ||
obj->collectionType() != CollectionType::Vector)) {
SystemLib::throwInvalidArgumentExceptionObject(
"Expected dependencies to be an instance of Vector");
}
assertx(collections::isType(obj->getVMClass(), CollectionType::Vector));
auto deps = req::ptr<c_Vector>::attach(c_Vector::Clone(obj));
auto ctx_idx = std::numeric_limits<context_idx_t>::max();
for (int64_t iter_pos = 0; iter_pos < deps->size(); ++iter_pos) {
Cell* current = deps->at(iter_pos);
auto const child = c_WaitHandle::fromCell(current);
if (UNLIKELY(!child)) {
SystemLib::throwInvalidArgumentExceptionObject(
"Expected dependencies to be a vector of WaitHandle instances");
}
if (!child->isFinished()) {
ctx_idx = std::min(
ctx_idx,
static_cast<c_WaitableWaitHandle*>(child)->getContextIdx()
);
}
}
Object exception;
for (int64_t iter_pos = 0; iter_pos < deps->size(); ++iter_pos) {
auto current = tvAssertCell(deps->at(iter_pos));
assert(current->m_type == KindOfObject);
assert(current->m_data.pobj->instanceof(c_WaitHandle::classof()));
auto child = static_cast<c_WaitHandle*>(current->m_data.pobj);
if (child->isSucceeded()) {
auto result = child->getResult();
deps->set(iter_pos, &result);
} else if (child->isFailed()) {
putException(exception, child->getException());
} else {
assert(child->instanceof(c_WaitableWaitHandle::classof()));
auto child_wh = static_cast<c_WaitableWaitHandle*>(child);
auto my_wh = req::make<c_GenVectorWaitHandle>();
my_wh->initialize(exception, deps.get(), iter_pos, ctx_idx, child_wh);
AsioSession* session = AsioSession::Get();
if (UNLIKELY(session->hasOnGenVectorCreate())) {
session->onGenVectorCreate(my_wh.get(), dependencies);
}
return Object(std::move(my_wh));
}
}
if (exception.isNull()) {
return Object::attach(c_StaticWaitHandle::CreateSucceeded(
make_tv<KindOfObject>(deps.detach())));
} else {
return Object::attach(c_StaticWaitHandle::CreateFailed(exception.detach()));
}
}