From 38fc2332e25c46a3936fca4eb857eca5883ef66e Mon Sep 17 00:00:00 2001 From: Alexey Rybalchenko Date: Fri, 3 Jun 2016 11:24:12 +0200 Subject: [PATCH] First version of the shared memory transport. Use via `--transport shmem` cmd option. No pub/sub. --- .../FairMQExample2Sampler.cxx | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/examples/MQ/2-sampler-processor-sink/FairMQExample2Sampler.cxx b/examples/MQ/2-sampler-processor-sink/FairMQExample2Sampler.cxx index b53b16dd..7ee5752e 100644 --- a/examples/MQ/2-sampler-processor-sink/FairMQExample2Sampler.cxx +++ b/examples/MQ/2-sampler-processor-sink/FairMQExample2Sampler.cxx @@ -34,19 +34,11 @@ void FairMQExample2Sampler::InitTask() bool FairMQExample2Sampler::ConditionalRun() { - std::this_thread::sleep_for(std::chrono::seconds(1)); + this_thread::sleep_for(chrono::seconds(1)); - // create a copy of the data with new(), that will be deleted after the transfer is complete - string* text = new string(fText); - - // create message object with a pointer to the data buffer, - // its size, - // custom deletion function (called when transfer is done), - // and pointer to the object managing the data buffer - FairMQMessagePtr msg(NewMessage(const_cast(text->c_str()), - text->length(), - [](void* /*data*/, void* object) { delete static_cast(object); }, - text)); + // Initializing message with NewStaticMessage will avoid copy + // but won't delete the data after the sending is completed. + FairMQMessagePtr msg(NewStaticMessage(fText)); LOG(INFO) << "Sending \"" << fText << "\"";