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


C++ OutputBuffer::reset方法代码示例

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


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

示例1: test_accept

bool test_accept(LocalNode &node)
        throw (EpiException)
{

    node.publishPort();

    std::auto_ptr<Connection> connection(node.accept());
    std::auto_ptr<MailBox> mailbox(node.createMailBox(connection.get()));
    connection->start();

    std::auto_ptr<ErlangMessage> msg;
    ErlTerm* received_term;
    OutputBuffer *buffer = mailbox->newOutputBuffer();

    bool loop = true;
    while (loop) {
        msg.reset(mailbox->receiveMsg());

        if (!(msg->messageType() == ERL_MSG_SEND ||
              msg->messageType() == ERL_MSG_REG_SEND)) {
            std::cout << "Message is not SEND type\n";
            return false;
        }

        received_term = msg->getMsg();

        if (msg->messageType() == ERL_MSG_REG_SEND) {
            std::cout << "Received to " << ((RegSendMessage *) msg.get())->getRecipientName() <<
                    ": " << received_term->toString() << "\n";
        } else {
            std::cout << "Received to " << ((SendMessage *) msg.get())->getRecipientPid()->toString() <<
                    ": " << received_term->toString() << "\n";
        }

        if (received_term->instanceOf(ERL_TUPLE)) {
            ErlTuple *tuple = (ErlTuple *) received_term;
            if (tuple->arity() == 2) {
                ErlTerm* term1 = tuple->elementAt(0);
                ErlTerm* term2 = tuple->elementAt(1);
                if (term1->instanceOf(ERL_PID)) {

                    std::cout << "Sending " << term2->toString() <<
                            " to " << term1->toString() << "\n";

                    buffer->reset();
                    buffer->writeTerm(term2);
                    mailbox->sendBuf((ErlPid *) term1, buffer);
                    std::cout << "Sent.\n";
                }
            }
        }

        if (received_term->instanceOf(ERL_ATOM)) {
            if (((ErlAtom *) received_term)->atomValue() == "exit") {
                loop = false;
            }
        }
    }
    return true;
}
开发者ID:srinathkattula,项目名称:epi,代码行数:60,代码来源:SelfNodeTest.cpp


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