本文整理汇总了C++中VM::getAtom方法的典型用法代码示例。如果您正苦于以下问题:C++ VM::getAtom方法的具体用法?C++ VM::getAtom怎么用?C++ VM::getAtom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VM
的用法示例。
在下文中一共展示了VM::getAtom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
gc<Object> ChannelObject::receive(VM& vm, gc<Fiber> receiver)
{
// If the channel is closed, immediately receive 'done'.
if (!isOpen_) return vm.getAtom(ATOM_DONE);
// If we have a sender, take its value.
if (senders_.count() > 0)
{
gc<Fiber> sender = senders_.removeAt(0);
return sender->sendValue();
}
// Otherwise, suspend.
receivers_.add(receiver);
return NULL;
}
示例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;
}