• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ msg_ptr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: qDebug

void
MsgProcessor::append( msg_ptr msg )
{
    if( QThread::currentThread() != thread() )
    {
        qDebug() << "reinvoking msgprocessor::append in correct thread, ie not" << QThread::currentThread();
        QMetaObject::invokeMethod( this, "append", Qt::QueuedConnection, Q_ARG(msg_ptr, msg) );
        return;
    }

    m_msgs.append( msg );
    m_msg_ready.insert( msg.data(), false );

    m_totmsgsize += msg->payload().length();

    if( m_mode & NOTHING )
    {
        //qDebug() << "MsgProcessor::NOTHING";
        handleProcessedMsg( msg );
        return;
    }

    QFuture<msg_ptr> fut = QtConcurrent::run(&MsgProcessor::process, msg, m_mode, m_threshold);
    QFutureWatcher<msg_ptr> * watcher = new QFutureWatcher<msg_ptr>;
    connect( watcher, SIGNAL( finished() ),
             this, SLOT( processed() ),
             Qt::QueuedConnection );

    watcher->setFuture( fut );
}
开发者ID:LittleForker,项目名称:tomahawk,代码行数:30,代码来源:msgprocessor.cpp


示例2: tDebug

void
Connection::sendMsg( msg_ptr msg )
{
    if ( d_func()->do_shutdown )
    {
        tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "SHUTTING DOWN, NOT SENDING msg flags:"
                             << (int)msg->flags() << "length:" << msg->length() << id();
        return;
    }

    d_func()->tx_bytes_requested += msg->length() + Msg::headerSize();
    d_func()->msgprocessor_out.append( msg );
}
开发者ID:Nskif,项目名称:tomahawk,代码行数:13,代码来源:Connection.cpp


示例3: qDebug

void
Connection::sendMsg( msg_ptr msg )
{
    if( m_do_shutdown )
    {
        qDebug() << Q_FUNC_INFO << "SHUTTING DOWN, NOT SENDING msg flags:"
                << (int)msg->flags() << "length:" << msg->length() << id();
        return;
    }

    m_tx_bytes_requested += msg->length() + Msg::headerSize();
    m_msgprocessor_out.append( msg );
}
开发者ID:MechanisM,项目名称:tomahawk,代码行数:13,代码来源:connection.cpp


示例4: if

void
ControlConnection::handleMsg( msg_ptr msg )
{
    if ( msg->is( Msg::PING ) )
    {
        // qDebug() << "Received Connection PING, nice." << m_pingtimer_mark.elapsed();
        m_pingtimer_mark.restart();
        return;
    }

    // if small and not compresed, print it out for debug
    if ( msg->length() < 1024 && !msg->is( Msg::COMPRESSED ) )
    {
        qDebug() << id() << "got msg:" << QString::fromLatin1( msg->payload() );
    }

    // All control connection msgs are JSON
    if ( !msg->is( Msg::JSON ) )
    {
        Q_ASSERT( msg->is( Msg::JSON ) );
        markAsFailed();
        return;
    }

    QVariantMap m = msg->json().toMap();
    if ( !m.isEmpty() )
    {
        if ( m.value( "conntype" ).toString() == "request-offer" )
        {
            QString theirkey = m["key"].toString();
            QString ourkey   = m["offer"].toString();
            QString theirdbid = m["controlid"].toString();
            servent()->reverseOfferRequest( this, theirdbid, ourkey, theirkey );
        }
        else if ( m.value( "method" ).toString() == "dbsync-offer" )
        {
            m_dbconnkey = m.value( "key" ).toString() ;
            setupDbSyncConnection();
        }
        else if ( m.value( "method" ) == "protovercheckfail" )
        {
            qDebug() << "*** Remote peer protocol version mismatch, connection closed";
            shutdown( true );
            return;
        }
        else
        {
            tDebug() << id() << "Unhandled msg:" << QString::fromLatin1( msg->payload() );
        }

        return;
    }

    tDebug() << id() << "Invalid msg:" << QString::fromLatin1( msg->payload() );
}
开发者ID:dsqmoore,项目名称:tomahawk,代码行数:55,代码来源:ControlConnection.cpp


示例5: Q_ASSERT

void
MsgProcessor::handleProcessedMsg( msg_ptr msg )
{
    Q_ASSERT( QThread::currentThread() == thread() );

    m_msg_ready.insert( msg.data(), true );

    while( !m_msgs.isEmpty() )
    {
        if( m_msg_ready.value( m_msgs.first().data() ) )
        {
            msg_ptr m = m_msgs.takeFirst();
            m_msg_ready.remove( m.data() );
            //qDebug() << Q_FUNC_INFO << "totmsgsize:" << m_totmsgsize;
            emit ready( m );
        }
        else
        {
            return;
        }
    }

    //qDebug() << Q_FUNC_INFO << "EMPTY, no msgs left.";
    emit empty();
}
开发者ID:LittleForker,项目名称:tomahawk,代码行数:25,代码来源:msgprocessor.cpp


示例6: while

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -    
vector<Resource*> SourceFacility::removeResource(msg_ptr msg) {
  Transaction trans = msg->trans();
  double sent_amt = 0;

  // pull materials off of the inventory stack until you get the trans amount

  // start with an empty manifest
  vector<Resource*> toSend;

  while (trans.resource->quantity() > (sent_amt+EPS_KG) && !inventory_.empty() ) {
    Material* m = inventory_.front();
    // if the inventory obj isn't larger than the remaining need, send it as is.
    if (m->quantity() <= (trans.resource->quantity() - sent_amt)) {
      sent_amt += m->quantity();
      toSend.push_back(m);
      inventory_.pop_front();
      LOG(LEV_DEBUG2) <<"SourceFacility "<< ID()
        <<"  has decided not to split the object with size :  "<< m->quantity();
    } else if (m->quantity() > (trans.resource->quantity() - sent_amt)) { 
      // if the inventory obj is larger than the remaining need, split it.
      Material* mat_to_send = m->extract(trans.resource->quantity() - sent_amt);
      sent_amt += mat_to_send->quantity();
      LOG(LEV_DEBUG2) <<"SourceFacility "<< ID()
        <<"  has decided to split the object to size :  "<< mat_to_send->quantity();
      toSend.push_back(mat_to_send);
      printSent(mat_to_send);
    }
  }    
  return toSend;
}
开发者ID:es5729,项目名称:core,代码行数:31,代码来源:SourceFacility.cpp


示例7: FakeConverterMarket

 FakeConverterMarket() : ConverterMarket() {
   string kg = "kg";
   string qual = "qual";
   gen_rsrc_ptr res = gen_rsrc_ptr(new GenericResource(kg, qual, 1));
   res->setOriginatorID(1);
   msg_ = msg_ptr(new Message(this));
   msg_->setResource(res);
 }
开发者ID:Simiopolis,项目名称:core,代码行数:8,代码来源:ConverterMarketTests.cpp


示例8: FakeConverterMarket

 FakeConverterMarket() : ConverterMarket() {
   string kg = "kg";
   string qual = "qual";
   gen_rsrc_ptr res = gen_rsrc_ptr(new GenericResource(kg, qual, 1));
   Transaction trans(this, OFFER);
   msg_ = msg_ptr(new Message(this, this, trans));
   msg_->trans().setResource(res);
 }
开发者ID:Sjenitzer,项目名称:cycamore,代码行数:8,代码来源:ConverterMarketTests.cpp


示例9: receiveMessage

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -    
void NullFacility::receiveMessage(msg_ptr msg) {
  // is this a message from on high? 
  if (msg->supplier()==this) {
    // file the order
    ordersWaiting_.push_front(msg);
  } else {
    throw CycException("NullFacility is not the supplier of this msg.");
  }
}
开发者ID:es5729,项目名称:core,代码行数:10,代码来源:NullFacility.cpp


示例10: processOrder

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
vector<rsrc_ptr> ConditioningFacility::removeResource(msg_ptr order) {
  vector<rsrc_ptr> toRet = vector<rsrc_ptr>() ;
  Transaction trans = order->trans();
  double order_amount = trans.resource->quantity()*trans.minfrac;
  if (remaining_capacity_ >= order_amount){
    toRet = processOrder(order);
  } else { 
    string msg;
    msg += "The ConditioningFacility has run out of processing capacity. ";
    msg += "The order requested by ";
    msg += order->requester()->name();
    msg += " will not be sent.";
    LOG(LEV_DEBUG2, "none!") << msg;
    gen_rsrc_ptr empty = gen_rsrc_ptr(new GenericResource("kg","kg",0));
    toRet.push_back(empty);
  }
  return toRet;
}
开发者ID:Simiopolis,项目名称:core,代码行数:19,代码来源:ConditioningFacility.cpp


示例11: receiveMessage

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -    
void BatchReactor::receiveMessage(msg_ptr msg) {
  // is this a message from on high? 
  if(msg->trans().supplier()==this){
    // file the order
    ordersWaiting_.push_front(msg);
    LOG(LEV_INFO5, "BReact") << name() << " just received an order.";
  }
  else {
    throw CycException("BatchReactor is not the supplier of this msg.");
  }
}
开发者ID:Sjenitzer,项目名称:cycamore,代码行数:12,代码来源:BatchReactor.cpp


示例12: addResource

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -    
void RecipeReactor::addResource(msg_ptr msg, vector<rsrc_ptr> manifest) {
  // grab each material object off of the manifest
  // and move it into the stocks.
  for (vector<rsrc_ptr>::iterator thisMat=manifest.begin();
       thisMat != manifest.end();
       thisMat++) {
    LOG(LEV_DEBUG2, "RReact") <<"RecipeReactor " << ID() << " is receiving material with mass "
        << (*thisMat)->quantity();
    stocks_.push_front(make_pair(msg->trans().commod, boost::dynamic_pointer_cast<Material>(*thisMat)));
  }
}
开发者ID:Simiopolis,项目名称:core,代码行数:12,代码来源:RecipeReactor.cpp


示例13: addResource

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ConditioningFacility::addResource(msg_ptr msg, vector<rsrc_ptr> manifest) {
  // Put the material received in the stocks
  // grab each material object off of the manifest
  // and move it into the stocks.
  for (vector<rsrc_ptr>::iterator thisMat=manifest.begin();
       thisMat != manifest.end();
       thisMat++) {
    LOG(LEV_DEBUG2, "none!") <<"ConditiondingFacility " << ID() << " is receiving material with mass "
        << (*thisMat)->quantity();

    mat_rsrc_ptr mat = boost::dynamic_pointer_cast<Material>(*thisMat);
    stocks_.push_front(make_pair(msg->trans().commod, mat));
  } 
};
开发者ID:Simiopolis,项目名称:core,代码行数:15,代码来源:ConditioningFacility.cpp


示例14: changeState

void
DBSyncConnection::handleMsg( msg_ptr msg )
{
    Q_ASSERT( !msg->is( Msg::COMPRESSED ) );

    if ( m_state == FETCHING )
        changeState( PARSING );

    // "everything is synced" indicated by non-json msg containing "ok":
    if ( !msg->is( Msg::JSON ) &&
         msg->is( Msg::DBOP ) &&
         msg->payload() == "ok" )
    {
        changeState( SYNCED );

        // calc the collection stats, to updates the "X tracks" in the sidebar etc
        // this is done automatically if you run a dbcmd to add files.
        DatabaseCommand_CollectionStats* cmd = new DatabaseCommand_CollectionStats( m_source );
        connect( cmd,           SIGNAL( done( const QVariantMap & ) ),
                 m_source.data(), SLOT( setStats( const QVariantMap& ) ), Qt::QueuedConnection );
        Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
        return;
    }
开发者ID:R4md4c,项目名称:tomahawk,代码行数:23,代码来源:DbSyncConnection.cpp


示例15: addResource

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SeparationsMatrixFacility::addResource(msg_ptr msg,
                                            vector<Resource*> manifest) {  
  LOG(LEV_DEBUG2) << "Entered the addResource file ";

  // grab each material object off of the manifest
  // and move it into the stocks.
  for (vector<Resource*>::iterator thisMat=manifest.begin();
      thisMat != manifest.end();
      thisMat++) {
    LOG(LEV_DEBUG2) <<"SeparationsFacility " << ID() << " is receiving material with mass "
      << (*thisMat)->quantity();
    stocks_.push_back(make_pair(msg->trans().commod, dynamic_cast<Material*>(*thisMat)));
  }
}
开发者ID:es5729,项目名称:core,代码行数:15,代码来源:SeparationsMatrixFacility.cpp


示例16: if

void
StreamConnection::handleMsg( msg_ptr msg )
{
    Q_ASSERT( msg->is( Msg::RAW ) );

    if ( msg->payload().startsWith( "block" ) )
    {
        int block = QString( msg->payload() ).mid( 5 ).toInt();
        m_readdev->seek( block * BufferIODevice::blockSize() );

        qDebug() << "Seeked to block:" << block;

        QByteArray sm;
        sm.append( QString( "doneblock%1" ).arg( block ) );

        sendMsg( Msg::factory( sm, Msg::RAW | Msg::FRAGMENT ) );
        QTimer::singleShot( 0, this, SLOT( sendSome() ) );
    }
    else if ( msg->payload().startsWith( "doneblock" ) )
    {
        int block = QString( msg->payload() ).mid( 9 ).toInt();
        ( (BufferIODevice*)m_iodev.data() )->seeked( block );

        m_curBlock = block;
        qDebug() << "Next block is now:" << block;
    }
    else if ( msg->payload().startsWith( "data" ) )
    {
        m_badded += msg->payload().length() - 4;
        ( (BufferIODevice*)m_iodev.data() )->addData( m_curBlock++, msg->payload().mid( 4 ) );
    }

    //qDebug() << Q_FUNC_INFO << "flags" << (int) msg->flags()
    //         << "payload len" << msg->payload().length()
    //         << "written to device so far: " << m_badded;

    if ( m_iodev && ( (BufferIODevice*)m_iodev.data() )->nextEmptyBlock() < 0 )
    {
        m_allok = true;

        // tell our iodev there is no more data to read, no args meaning a success:
        ( (BufferIODevice*)m_iodev.data() )->inputComplete();

        shutdown();
    }
}
开发者ID:Knarf64,项目名称:tomahawk-resolvers,代码行数:46,代码来源:StreamConnection.cpp


示例17: on_protobuf_msg

		void on_protobuf_msg(session_ptr& impl, const msg_ptr& message)
		{
			callback_container::mapped_type tmp;
			callbacks_.op_if(message->GetDescriptor(), [&tmp](const callback_container::value_type &val)
			{
				tmp = val.second;
			});

			if( tmp != 0 )
			{
				tmp->on_msg(impl, message);
			}
			else
			{
				default_handler_(std::ref(impl), std::cref(message));
			}
		}
开发者ID:chenyu2202863,项目名称:smart_cpp_lib,代码行数:17,代码来源:dispacther.cpp


示例18: while

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -    
vector<rsrc_ptr> RecipeReactor::removeResource(msg_ptr msg) {
  Transaction trans = msg->trans();

  double newAmt = 0;

  mat_rsrc_ptr m;
  mat_rsrc_ptr newMat;
  mat_rsrc_ptr toAbsorb;

  // start with an empty manifest
  vector<rsrc_ptr> toSend;

  // pull materials off of the inventory stack until you get the trans amount
  while (trans.resource->quantity() > newAmt && !inventory_.empty() ) {
    for (deque<Fuel>::iterator iter = inventory_.begin(); 
        iter != inventory_.end(); 
        iter ++){
      // be sure to get the right commodity
      if (iter->first == trans.commod) {
        m = iter->second;

        // start with an empty material
        newMat = mat_rsrc_ptr(new Material());

        // if the inventory obj isn't larger than the remaining need, send it as is.
        if (m->quantity() <= (trans.resource->quantity() - newAmt)) {
          newAmt += m->quantity();
          newMat->absorb(m);
          inventory_.pop_front();
        } else { 
          // if the inventory obj is larger than the remaining need, split it.
          toAbsorb = m->extract(trans.resource->quantity() - newAmt);
          newAmt += toAbsorb->quantity();
          newMat->absorb(toAbsorb);
        }
        toSend.push_back(newMat);
        LOG(LEV_DEBUG2, "RReact") <<"RecipeReactor "<< ID()
          <<"  is sending a mat with mass: "<< newMat->quantity();
      }
    }
  }    
  return toSend;
}
开发者ID:Simiopolis,项目名称:core,代码行数:44,代码来源:RecipeReactor.cpp


示例19: thread

void
Connection::sendMsg_now( msg_ptr msg )
{
    Q_ASSERT( QThread::currentThread() == thread() );
//    Q_ASSERT( this->isRunning() );

    if ( m_sock.isNull() || !m_sock->isOpen() || !m_sock->isWritable() )
    {
        tDebug() << "***** Socket problem, whilst in sendMsg(). Cleaning up. *****";
        shutdown( false );
        return;
    }

    if ( !msg->write( m_sock.data() ) )
    {
        //qDebug() << "Error writing to socket in sendMsg() *************";
        shutdown( false );
        return;
    }
}
开发者ID:norrs,项目名称:tomahawk,代码行数:20,代码来源:Connection.cpp


示例20: CycException

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -    
vector<rsrc_ptr> StorageFacility::removeResource(msg_ptr order) {
  Transaction trans = order->trans();
  // it should be of incommod Commodity type
  if(trans.commod != incommod_){
    throw CycException("StorageFacility can only send incommodity type materials.");
  }
  // pull materials off of the inventory_ stack until you get the trans amount
  Mass complete = 0;

  // start with an empty manifest
  vector<rsrc_ptr> toSend;

  while(trans.amount > complete && !inventory_.empty() ){
    mat_rsrc_ptr m = inventory_.front();

    // if the inventory_ obj isn't larger than the remaining need, send it as is.
    if(m->quantity() <= (capacity_ - complete)){
      complete += m->quantity();
      toSend.push_back(m);
      LOG(LEV_DEBUG2, "none!") <<"StorageFacility "<< getSN()
        <<"  is sending a mat with mass: "<< m->quantity();
      inventory_.pop_front();
    } else { 
      // if the inventory_ obj is larger than the remaining need, split it.
      // start with an empty material
      mat_rsrc_ptr newMat = mat_rsrc_ptr(new Material(CompMap(), 
          m->getUnits(),
          m->getName(), 
          0, ATOMBASED);
      mat_rsrc_ptr toAbsorb = m->extractMass(capacity_ - complete);
      complete += toAbsorb->quantity();
      newMat->absorb(toAbsorb);
      toSend.push_back(newMat);
      LOG(LEV_DEBUG2, "none!") <<"StorageFacility "<< getSN()
        <<"  is sending a mat with mass: "<< newMat->quantity();
    }
  }    
  return toSend;
}
开发者ID:Simiopolis,项目名称:core,代码行数:40,代码来源:StorageFacility.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ msg_t类代码示例发布时间:2022-05-31
下一篇:
C++ mrs_string类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap