mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-16 10:01:47 +00:00
- Add multipart support to the interface and enable its use out of tasks.
Examples on the use out of tasks are provided in: `example/Tutorial3/digitization/TestDetectorDigiLoader.tpl:76-85`: sending a part. `example/Tutorial3/reconstruction/FairTestDetectorMQRecoTask.tpl:177-182`: receiving a part. - This commit also makes structure within processorTask more consistent with samplerTask. - add macro MQLOG to FairMQLogger.
This commit is contained in:
@@ -37,6 +37,12 @@ FairMQMessageNN::FairMQMessageNN(size_t size)
|
||||
fReceiving = false;
|
||||
}
|
||||
|
||||
|
||||
/* nanomsg does not offer support for creating a message out of an existing buffer,
|
||||
* therefore the following method is using memcpy. For more efficient handling,
|
||||
* create FairMQMessage object only with size parameter and fill it with data.
|
||||
* possible TODO: make this zero copy (will should then be as efficient as ZeroMQ).
|
||||
*/
|
||||
FairMQMessageNN::FairMQMessageNN(void* data, size_t size, fairmq_free_fn *ffn, void* hint)
|
||||
{
|
||||
fMessage = nn_allocmsg(size, 0);
|
||||
|
@@ -69,7 +69,7 @@ void FairMQSocketNN::Connect(const string& address)
|
||||
}
|
||||
}
|
||||
|
||||
size_t FairMQSocketNN::Send(FairMQMessage* msg)
|
||||
size_t FairMQSocketNN::Send(FairMQMessage* msg, const string& flag)
|
||||
{
|
||||
void* ptr = msg->GetMessage();
|
||||
int rc = nn_send(fSocket, &ptr, NN_MSG, 0);
|
||||
@@ -87,7 +87,7 @@ size_t FairMQSocketNN::Send(FairMQMessage* msg)
|
||||
return rc;
|
||||
}
|
||||
|
||||
size_t FairMQSocketNN::Receive(FairMQMessage* msg)
|
||||
size_t FairMQSocketNN::Receive(FairMQMessage* msg, const string& flag)
|
||||
{
|
||||
void* ptr = NULL;
|
||||
int rc = nn_recv(fSocket, &ptr, NN_MSG, 0);
|
||||
@@ -130,6 +130,14 @@ void FairMQSocketNN::SetOption(const string& option, const void* value, size_t v
|
||||
}
|
||||
}
|
||||
|
||||
void FairMQSocketNN::GetOption(const string& option, void* value, size_t* valueSize)
|
||||
{
|
||||
int rc = nn_getsockopt(fSocket, NN_SOL_SOCKET, GetConstant(option), value, valueSize);
|
||||
if (rc < 0) {
|
||||
LOG(ERROR) << "failed getting socket option, reason: " << nn_strerror(errno);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long FairMQSocketNN::GetBytesTx()
|
||||
{
|
||||
return fBytesTx;
|
||||
@@ -152,6 +160,8 @@ unsigned long FairMQSocketNN::GetMessagesRx()
|
||||
|
||||
int FairMQSocketNN::GetConstant(const string& constant)
|
||||
{
|
||||
if (constant == "")
|
||||
return 0;
|
||||
if (constant == "sub")
|
||||
return NN_SUB;
|
||||
if (constant == "pub")
|
||||
@@ -168,6 +178,14 @@ int FairMQSocketNN::GetConstant(const string& constant)
|
||||
return NN_SNDBUF;
|
||||
if (constant == "rcv-hwm")
|
||||
return NN_RCVBUF;
|
||||
if (constant == "snd-more") {
|
||||
LOG(ERROR) << "Multipart messages functionality currently not supported by nanomsg!";
|
||||
return -1;
|
||||
}
|
||||
if (constant == "rcv-more") {
|
||||
LOG(ERROR) << "Multipart messages functionality currently not supported by nanomsg!";
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@@ -31,14 +31,15 @@ class FairMQSocketNN : public FairMQSocket
|
||||
virtual void Bind(const string& address);
|
||||
virtual void Connect(const string& address);
|
||||
|
||||
virtual size_t Send(FairMQMessage* msg);
|
||||
virtual size_t Receive(FairMQMessage* msg);
|
||||
virtual size_t Send(FairMQMessage* msg, const string& flag="");
|
||||
virtual size_t Receive(FairMQMessage* msg, const string& flag="");
|
||||
|
||||
virtual void* GetSocket();
|
||||
virtual int GetSocket(int nothing);
|
||||
virtual void Close();
|
||||
|
||||
virtual void SetOption(const string& option, const void* value, size_t valueSize);
|
||||
virtual void GetOption(const string& option, void* value, size_t* valueSize);
|
||||
|
||||
unsigned long GetBytesTx();
|
||||
unsigned long GetBytesRx();
|
||||
|
Reference in New Issue
Block a user