mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-18 19:11:45 +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,9 +5,11 @@
|
||||
* Author: dklein
|
||||
*/
|
||||
|
||||
#include "FairMQBalancedStandaloneSplitter.h"
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQBalancedStandaloneSplitter.h"
|
||||
|
||||
FairMQBalancedStandaloneSplitter::FairMQBalancedStandaloneSplitter()
|
||||
{
|
||||
@@ -19,11 +21,9 @@ FairMQBalancedStandaloneSplitter::~FairMQBalancedStandaloneSplitter()
|
||||
|
||||
void FairMQBalancedStandaloneSplitter::Run()
|
||||
{
|
||||
void* status; //necessary for pthread_join
|
||||
FairMQLogger::GetInstance()->Log(FairMQLogger::INFO, ">>>>>>> Run <<<<<<<");
|
||||
|
||||
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[] = {
|
||||
@@ -31,27 +31,27 @@ void FairMQBalancedStandaloneSplitter::Run()
|
||||
};
|
||||
|
||||
Bool_t received = false;
|
||||
Bool_t direction = false;
|
||||
while (true) {
|
||||
Int_t direction = 0;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (received) {
|
||||
if (direction) {
|
||||
fPayloadOutputs->at(0)->Send(&msg);
|
||||
} else {
|
||||
fPayloadOutputs->at(1)->Send(&msg);
|
||||
fPayloadOutputs->at(direction)->Send(&msg);
|
||||
direction++;
|
||||
if (direction >= fNumOutputs) {
|
||||
direction = 0;
|
||||
}
|
||||
direction = !direction;
|
||||
}
|
||||
received = false;
|
||||
}//if received
|
||||
}
|
||||
|
||||
pthread_join(logger, &status);
|
||||
rateLogger.interrupt();
|
||||
rateLogger.join();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user