本文整理汇总了C++中gc::ready方法的典型用法代码示例。如果您正苦于以下问题:C++ gc::ready方法的具体用法?C++ gc::ready怎么用?C++ gc::ready使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gc
的用法示例。
在下文中一共展示了gc::ready方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: send
void ChannelObject::send(gc<Fiber> sender, gc<Object> value)
{
// TODO(bob): What if the channel is closed?
// If we have a receiver, give it the value.
if (receivers_.count() > 0)
{
gc<Fiber> receiver = receivers_.removeAt(0);
receiver->storeReturn(value);
receiver->ready();
// Add the sender back to the scheduler too since it isn't blocked.
sender->ready();
return;
}
// Otherwise, stuff the value and suspend.
sender->waitToSend(value);
senders_.add(sender);
return;
}
示例2: close
bool ChannelObject::close(VM& vm, gc<Fiber> sender)
{
if (!isOpen_) return false;
isOpen_ = false;
// If nothing is going to receive the "done". Just ignore it and close
// immediately.
if (receivers_.count() == 0) return false;
// Send "done" to all of the receivers.
for (int i = 0; i < receivers_.count(); i++)
{
receivers_[i]->storeReturn(vm.getAtom(ATOM_DONE));
receivers_[i]->ready();
}
receivers_.clear();
// Add the sender back to the scheduler after the receiver so it can
// continue.
sender->ready();
return true;
}