mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-16 10:01:47 +00:00
merge the trunk with the development of ZeroMQ branch
git-svn-id: https://subversion.gsi.de/fairroot/fairbase/trunk@22451 0381ead4-6506-0410-b988-94b70fbc4730
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
* Author: dklein
|
||||
*/
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "FairMQProcessor.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
@@ -34,32 +37,42 @@ void FairMQProcessor::Run()
|
||||
{
|
||||
FairMQLogger::GetInstance()->Log(FairMQLogger::INFO, ">>>>>>> Run <<<<<<<");
|
||||
|
||||
void* status; //necessary for pthread_join
|
||||
pthread_t logger;
|
||||
pthread_create(&logger, NULL, &FairMQDevice::callLogSocketRates, this);
|
||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
||||
|
||||
// Initialize poll set
|
||||
zmq_pollitem_t items[] = {
|
||||
{ *(fPayloadInputs->at(0)->GetSocket()), 0, ZMQ_POLLIN, 0 }
|
||||
};
|
||||
|
||||
int receivedMsgs = 0;
|
||||
int sentMsgs = 0;
|
||||
|
||||
Bool_t received = false;
|
||||
while (true) {
|
||||
|
||||
while ( fState == RUNNING ) {
|
||||
FairMQMessage msg;
|
||||
|
||||
zmq_poll(items, 1, -1);
|
||||
zmq_poll(items, 1, 100);
|
||||
|
||||
if (items[0].revents & ZMQ_POLLIN) {
|
||||
received = fPayloadInputs->at(0)->Receive(&msg);
|
||||
receivedMsgs++;
|
||||
}
|
||||
|
||||
if (received) {
|
||||
fTask->Exec(&msg, NULL);
|
||||
|
||||
fPayloadOutputs->at(0)->Send(&msg);
|
||||
sentMsgs++;
|
||||
received = false;
|
||||
}
|
||||
}
|
||||
|
||||
pthread_join(logger, &status);
|
||||
std::cout << "I've received " << receivedMsgs << " and sent " << sentMsgs << " messages!" << std::endl;
|
||||
|
||||
boost::this_thread::sleep(boost::posix_time::milliseconds(5000));
|
||||
|
||||
rateLogger.interrupt();
|
||||
rateLogger.join();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user