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


C++ Duration::getMilliseconds方法代码示例

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


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

示例1: query

ConsoleEvent AgentImpl::query(const Query& query, Duration timeout)
{
    boost::shared_ptr<SyncContext> context(new SyncContext());
    uint32_t correlator(session.correlator());
    ConsoleEvent result;

    {
        qpid::sys::Mutex::ScopedLock l(lock);
        contextMap[correlator] = context;
    }
    try {
        sendQuery(query, correlator);
        {
            uint64_t milliseconds = timeout.getMilliseconds();
            qpid::sys::Mutex::ScopedLock cl(context->lock);
            if (!context->response.isValid() || !context->response.isFinal())
                context->cond.wait(context->lock,
                                   qpid::sys::AbsTime(qpid::sys::now(),
                                                      qpid::sys::Duration(milliseconds * qpid::sys::TIME_MSEC)));
            if (context->response.isValid() &&
                ((context->response.getType() == CONSOLE_QUERY_RESPONSE && context->response.isFinal()) ||
                 (context->response.getType() == CONSOLE_EXCEPTION)))
                result = context->response;
            else {
                auto_ptr<ConsoleEventImpl> impl(new ConsoleEventImpl(CONSOLE_EXCEPTION));
                Data exception(new DataImpl());
                exception.setProperty("error_text", "Timed out waiting for the agent to respond");
                impl->addData(exception);
                result = ConsoleEvent(impl.release());
            }
        }
    } catch (qpid::types::Exception&) {
    }

    {
        qpid::sys::Mutex::ScopedLock l(lock);
        contextMap.erase(correlator);
    }

    return result;
}
开发者ID:ChugR,项目名称:qpid-cpp,代码行数:41,代码来源:Agent.cpp

示例2: callMethod

ConsoleEvent AgentImpl::callMethod(const string& method, const Variant::Map& args, const DataAddr& addr, Duration timeout)
{
    boost::shared_ptr<SyncContext> context(new SyncContext());
    uint32_t correlator(session.correlator());
    ConsoleEvent result;

    {
        qpid::sys::Mutex::ScopedLock l(lock);
        contextMap[correlator] = context;
    }
    try {
        sendMethod(method, args, addr, correlator);
        {
            uint64_t milliseconds = timeout.getMilliseconds();
            qpid::sys::Mutex::ScopedLock cl(context->lock);
            if (!context->response.isValid())
                context->cond.wait(context->lock,
                                   qpid::sys::AbsTime(qpid::sys::now(),
                                                      qpid::sys::Duration(milliseconds * qpid::sys::TIME_MSEC)));
            if (context->response.isValid())
                result = context->response;
            else {
                auto_ptr<ConsoleEventImpl> impl(new ConsoleEventImpl(CONSOLE_EXCEPTION));
                Data exception(new DataImpl());
                exception.setProperty("error_text", "Timed out waiting for the agent to respond");
                impl->addData(exception);
                result = ConsoleEvent(impl.release());
            }
        }
    } catch (qpid::types::Exception&) {
    }

    {
        qpid::sys::Mutex::ScopedLock l(lock);
        contextMap.erase(correlator);
    }

    return result;
}
开发者ID:ChugR,项目名称:qpid-cpp,代码行数:39,代码来源:Agent.cpp

示例3:

bool operator!=(const Duration& a, const Duration& b)
{
    return a.getMilliseconds() != b.getMilliseconds();
}
开发者ID:ChugR,项目名称:qpid-cpp,代码行数:4,代码来源:Duration.cpp

示例4: run

void RequestResponse::run()
{
    const char *options[] = {"", "--log-enable", "trace+", "--log-to-stdout", "on", "--log-time", "on", "--log-level", "on"};
    Logger::configure(9, options);

    std::string url = "amqp:ssl:" + _options.getHost() + ":" + std::to_string(_options.getPort());

    Connection connection(url, "{ protocol: amqp1.0 }");
    connection.setOption("sasl_mechanisms", "EXTERNAL");
    connection.setOption("heartbeat", "30");

    Address reply(_replyAddress);
    Address request(_requestAddress);
    Address response(_responseAddress);

    Duration timeout = Duration::SECOND * _options.getTimeout();

    try
    {
        connection.open();
        Session session = connection.createSession();

        std::cout << "-I- Connection opened, session created" << std::endl;

        Sender sender = session.createSender(request);
        sender.setCapacity(_capacity);

        std::cout << "-I- Sender created " << sender.getName() << std::endl;

        Receiver receiver = session.createReceiver(response);
        receiver.setCapacity(_capacity);

        std::cout << "-I- Receiver created " << receiver.getName() << std::endl;

        Message requestMsg("<FIXML>...</FIXML>");
        requestMsg.setDurable(false);
        requestMsg.setReplyTo(reply);
        sender.send(requestMsg, true);

        std::cout << "-I- Request message sent" << std::endl;

        try
        {
            Message responseMsg = receiver.fetch(timeout);

            std::cout << "-I- Received message with content: " << responseMsg.getContent() << std::endl;

            session.acknowledge(true);

            _messageCounter++;
        }
        catch (NoMessageAvailable noMessage)
        {
            std::cout << "-I- No message received for " << timeout.getMilliseconds()/1000 << " seconds" << std::endl;
        }

        session.sync(true);

        sender.close();
        receiver.close();
        session.close();
        connection.close();
    }
    catch (const std::exception &error)
    {
        connection.close();
        std::cerr << "-E- Caught exception: " << error.what() << std::endl;
        throw error;
    }
}
开发者ID:Eurex-Clearing-Messaging-Interfaces,项目名称:C-Code-Examples,代码行数:70,代码来源:RequestResponse.cpp

示例5: Duration

Duration operator*(uint64_t multiplier, const Duration& duration)
{
    return Duration(duration.getMilliseconds() * multiplier);
}
开发者ID:ChugR,项目名称:qpid-cpp,代码行数:4,代码来源:Duration.cpp


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