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


C++ msg_ptr类代码示例

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


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


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