FairMQ: Add functionality to set used message size

This commit is contained in:
Alexey Rybalchenko
2017-12-05 12:51:07 +01:00
committed by Mohammad Al-Turany
parent ac4695b215
commit e5aa85b61d
10 changed files with 250 additions and 98 deletions

View File

@@ -1,8 +1,8 @@
/********************************************************************************
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
/**
@@ -141,11 +141,27 @@ void* FairMQMessageNN::GetData()
return fMessage;
}
size_t FairMQMessageNN::GetSize()
size_t FairMQMessageNN::GetSize() const
{
return fSize;
}
bool FairMQMessageNN::SetUsedSize(const size_t size)
{
if (size <= fSize)
{
// with size smaller than original nanomsg will simply "chop" the data, avoiding reallocation
fMessage = nn_reallocmsg(fMessage, size);
fSize = size;
return true;
}
else
{
LOG(ERROR) << "FairMQMessageNN::SetUsedSize: cannot set used size higher than original.";
return false;
}
}
void FairMQMessageNN::SetMessage(void* data, const size_t size)
{
fMessage = data;