Enable new callback API

- OnData() channel data handler.
 - ConditionalRun() for devices without incoming data.
 - Header file with common main(), to be extended with getDevice/addCustomOptions.
 - Update examples (MQ/Tutorial3) to use the new API and config.
 - NewSimpleMessage() for simpler creation of small messages (additional copy).
 - Replace SetProperty/GetProperty with fConfig access.
 - Runtime configurable channel names for common devices.
 - Configurable logging interval per channel.
 - FairMQMultiplier for distributing same data to multiple outputs.
 - Cleanup state machine messages.
 - Cmd option to toggle signal handling.
 - Simpler API for send/receive timeouts.
 - Enable --log-to-file.
 - Fix coverity issues, warnings.
 - Various code cleanup and minor tweaks.
This commit is contained in:
Alexey Rybalchenko
2016-08-10 09:47:53 +02:00
committed by Mohammad Al-Turany
parent d5b98567db
commit da10c64800
53 changed files with 501 additions and 1263 deletions

View File

@@ -12,10 +12,8 @@
* @author A. Rybalchenko
*/
#include <memory> // unique_ptr
#include <string>
#include <boost/thread.hpp>
#include <thread> // this_thread::sleep_for
#include <chrono>
#include "FairMQExample6Broadcaster.h"
#include "FairMQLogger.h"
@@ -26,22 +24,19 @@ FairMQExample6Broadcaster::FairMQExample6Broadcaster()
{
}
void FairMQExample6Broadcaster::CustomCleanup(void* /*data*/, void *object)
bool FairMQExample6Broadcaster::ConditionalRun()
{
delete static_cast<string*>(object);
}
this_thread::sleep_for(chrono::seconds(1));
void FairMQExample6Broadcaster::Run()
{
while (CheckCurrentState(RUNNING))
{
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
// Should only be used for small data because of the cost of an additional copy
FairMQMessagePtr msg(NewSimpleMessage("OK"));
string* text = new string("OK");
unique_ptr<FairMQMessage> msg(NewMessage(const_cast<char*>(text->c_str()), text->length(), CustomCleanup, text));
LOG(INFO) << "Sending OK";
Send(msg, "broadcast");
}
LOG(INFO) << "Sending OK";
Send(msg, "broadcast");
return true;
}
FairMQExample6Broadcaster::~FairMQExample6Broadcaster()