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


C++ VERIFY_CORRECT_THREAD函数代码示例

本文整理汇总了C++中VERIFY_CORRECT_THREAD函数的典型用法代码示例。如果您正苦于以下问题:C++ VERIFY_CORRECT_THREAD函数的具体用法?C++ VERIFY_CORRECT_THREAD怎么用?C++ VERIFY_CORRECT_THREAD使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: VERIFY_CORRECT_THREAD

    void message_oriented_connection_impl::destroy_connection()
    {
      VERIFY_CORRECT_THREAD();

      fc::optional<fc::ip::endpoint> remote_endpoint;
      if (_sock.get_socket().is_open())
        remote_endpoint = _sock.get_socket().remote_endpoint();
      ilog( "in destroy_connection() for ${endpoint}", ("endpoint", remote_endpoint) );

      if (_send_message_in_progress)
        elog("Error: message_oriented_connection is being destroyed while a send_message is in progress.  "
             "The task calling send_message() should have been canceled already");
      assert(!_send_message_in_progress);

      try
      {
        _read_loop_done.cancel_and_wait(__FUNCTION__);
      }
      catch ( const fc::exception& e )
      {
        wlog( "Exception thrown while canceling message_oriented_connection's read_loop, ignoring: ${e}", ("e",e) );
      }
      catch (...)
      {
        wlog( "Exception thrown while canceling message_oriented_connection's read_loop, ignoring" );
      }
    }
开发者ID:NewportHighlander,项目名称:PTS,代码行数:27,代码来源:message_oriented_connection.cpp

示例2: VERIFY_CORRECT_THREAD

    void peer_connection::send_queueable_message(std::unique_ptr<queued_message>&& message_to_send)
    {
      VERIFY_CORRECT_THREAD();
      _total_queued_messages_size += message_to_send->get_size_in_queue();
      _queued_messages.emplace(std::move(message_to_send));
      if (_total_queued_messages_size > GRAPHENE_NET_MAXIMUM_QUEUED_MESSAGES_IN_BYTES)
      {
        elog("send queue exceeded maximum size of ${max} bytes (current size ${current} bytes)",
             ("max", GRAPHENE_NET_MAXIMUM_QUEUED_MESSAGES_IN_BYTES)("current", _total_queued_messages_size));
        try
        {
          close_connection();
        }
        catch (const fc::exception& e)
        {
          elog("Caught error while closing connection: ${exception}", ("exception", e));
        }
        return;
      }

      if( _send_queued_messages_done.valid() && _send_queued_messages_done.canceled() )
        FC_THROW_EXCEPTION(fc::exception, "Attempting to send a message on a connection that is being shut down");

      if (!_send_queued_messages_done.valid() || _send_queued_messages_done.ready())
      {
        dlog("peer_connection::send_message() is firing up send_queued_message_task");
        _send_queued_messages_done = fc::async([this](){ send_queued_messages_task(); }, "send_queued_messages_task");
      }
      else
        dlog("peer_connection::send_message() doesn't need to fire up send_queued_message_task, it's already running");
    }
开发者ID:todasun,项目名称:graphene,代码行数:31,代码来源:peer_connection.cpp

示例3: VERIFY_CORRECT_THREAD

 void peer_connection::on_message( message_oriented_connection* originating_connection, const message& received_message )
 {
   VERIFY_CORRECT_THREAD();
   _currently_handling_message = true;
   BOOST_SCOPE_EXIT(this_) {
     this_->_currently_handling_message = false;
   } BOOST_SCOPE_EXIT_END
   _node->on_message( this, received_message );
 }
开发者ID:Gandalf-the-Grey,项目名称:steem,代码行数:9,代码来源:peer_connection.cpp

示例4: VERIFY_CORRECT_THREAD

    void message_oriented_connection_impl::send_message(const message& message_to_send)
    {
      VERIFY_CORRECT_THREAD();
#if 0 // this gets too verbose
#ifndef NDEBUG
      fc::optional<fc::ip::endpoint> remote_endpoint;
      if (_sock.get_socket().is_open())
        remote_endpoint = _sock.get_socket().remote_endpoint();
      struct scope_logger {
        const fc::optional<fc::ip::endpoint>& endpoint;
        scope_logger(const fc::optional<fc::ip::endpoint>& endpoint) : endpoint(endpoint) { dlog("entering message_oriented_connection::send_message() for peer ${endpoint}", ("endpoint", endpoint)); }
        ~scope_logger() { dlog("leaving message_oriented_connection::send_message() for peer ${endpoint}", ("endpoint", endpoint)); }
      } send_message_scope_logger(remote_endpoint);
#endif
#endif
      struct verify_no_send_in_progress {
        bool& var;
        verify_no_send_in_progress(bool& var) : var(var)
        {
          if (var)
            elog("Error: two tasks are calling message_oriented_connection::send_message() at the same time");
          assert(!var);
          var = true;
        }
        ~verify_no_send_in_progress() { var = false; }
      } _verify_no_send_in_progress(_send_message_in_progress);

      try
      {
        size_t size_of_message_and_header = sizeof(message_header) + message_to_send.size;
        if( message_to_send.size > MAX_MESSAGE_SIZE )
           elog("Trying to send a message larger than MAX_MESSAGE_SIZE. This probably won't work...");
        //pad the message we send to a multiple of 16 bytes
        size_t size_with_padding = 16 * ((size_of_message_and_header + 15) / 16);
        std::unique_ptr<char[]> padded_message(new char[size_with_padding]);

        memcpy(padded_message.get(), (char*)&message_to_send, sizeof(message_header));
        memcpy(padded_message.get() + sizeof(message_header), message_to_send.data.data(), message_to_send.size );
        char* paddingSpace = padded_message.get() + sizeof(message_header) + message_to_send.size;
        size_t toClean = size_with_padding - size_of_message_and_header;
        memset(paddingSpace, 0, toClean);

        _sock.write(padded_message.get(), size_with_padding);
        _sock.flush();
        _bytes_sent += size_with_padding;
        _last_message_sent_time = fc::time_point::now();
      } FC_RETHROW_EXCEPTIONS( warn, "unable to send message" );
    }
开发者ID:mingyukim123,项目名称:steem,代码行数:48,代码来源:message_oriented_connection.cpp


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