Skip to content
This repository was archived by the owner on Oct 17, 2019. It is now read-only.

Commit 2ab321f

Browse files
committed
use a ptr instead of a vector to keep reference
1 parent d52e611 commit 2ab321f

File tree

4 files changed

+37
-30
lines changed

4 files changed

+37
-30
lines changed

DataSampling/include/DataSampling/MockInjector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ class MockInjector: public InjectorInterface
2424
///
2525
/// @todo Make it a class, add namespaces, rename.
2626
///
27-
/// \param dataBlocks A reference to a vector of data blocks. All data blocks in the vector have the same event id.
27+
/// \param dataSet A reference to a vector of data blocks. All data blocks in the vector have the same event id.
2828
/// \return 0 on success, an error code otherwise
29-
int injectSamples(DataSetReference dataBlocks) override;
29+
int injectSamples(DataSetReference dataSet) override;
3030

3131
};
3232

DataSampling/src/FairInjector.cxx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@ FairInjector::~FairInjector()
4545
ChangeState(END);
4646
}
4747

48-
std::map<void*, DataBlockContainerReference> store;
48+
//std::map<void *, DataBlockContainerReference> store;
4949

5050
void cleanupCallback(void *data, void *object)
5151
{
52-
if (data != nullptr) {
53-
store.erase(data);
52+
// if (data != nullptr) {
53+
// store.erase(data);
54+
// }
55+
if ((object!=nullptr)&&(data!=nullptr)) {
56+
DataBlockContainerReference *ptr=(DataBlockContainerReference *)object;
57+
delete ptr;
5458
}
5559
}
5660

@@ -63,10 +67,11 @@ int FairInjector::injectSamples(DataSetReference dataSetReference)
6367
char *data = block->getData()->data;
6468

6569
// just to keep reference alive
66-
store[data] = block;
70+
// store[data] = block;
71+
DataBlockContainerReference *ptr = new DataBlockContainerReference(block);
6772

6873
FairMQMessagePtr msgHeader(NewMessage((void *) &header, (header.headerSize), cleanupCallback, (void *) nullptr));
69-
FairMQMessagePtr msgBody(NewMessage((void *) data, (header.dataSize), cleanupCallback));
74+
FairMQMessagePtr msgBody(NewMessage((void *) data, (header.dataSize), cleanupCallback, (void *) (ptr)));
7075

7176
parts.AddPart(std::move(msgHeader));
7277
parts.AddPart(std::move(msgBody));

DataSampling/src/MockInjector.cxx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,22 @@
99
namespace AliceO2 {
1010
namespace DataSampling {
1111

12-
// TODO use MockDataBlockContainer like in DataBlockProducer
13-
int MockInjector::injectSamples(DataSetReference dataBlocks)
12+
int MockInjector::injectSamples(DataSetReference dataSet)
1413
{
15-
unsigned int nBlocks = (int) dataBlocks->size();
16-
int totalSize = 0;
17-
for (DataBlockContainerReference blockContainer : *dataBlocks) {
18-
DataBlockHeaderBase *header = &blockContainer->getData()->header;
19-
void *payload = blockContainer->getData()->data;
20-
unsigned int blockSize = header->dataSize;
21-
printf("%p : %d\n", payload, blockSize);
22-
totalSize += blockSize;
23-
}
24-
25-
printf("DataSampling injection: got %u blocks, total size %u bytes\n", nBlocks, totalSize);
14+
// TODO we don't want to slow down the caller, thus we do nothing...
15+
// TODO This being said we might want in certain cases to print the stuff below.
16+
//
17+
// unsigned int nBlocks = (int) dataSet->size();
18+
// int totalSize = 0;
19+
// for (DataBlockContainerReference blockContainer : *dataSet) {
20+
// DataBlockHeaderBase *header = &blockContainer->getData()->header;
21+
// void *payload = blockContainer->getData()->data;
22+
// unsigned int blockSize = header->dataSize;
23+
// printf("%p : %d\n", payload, blockSize);
24+
// totalSize += blockSize;
25+
// }
26+
//
27+
// printf("DataSampling injection: got %u blocks, total size %u bytes\n", nBlocks, totalSize);
2628
return 0;
2729
}
2830

Readout/src/ConsumerStats.cxx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ using namespace AliceO2::Monitoring;
1616

1717

1818
// macro to get number of element in static array
19-
#define STATIC_ARRAY_ELEMENT_COUNT(x) sizeof(x)/sizeof(x[0])
19+
#define STATIC_ARRAY_ELEMENT_COUNT(x) sizeof(x)/sizeof(x[0])
2020

2121
// function to convert a value in bytes to a prefixed number 3+3 digits
2222
// suffix is the "base unit" to add after calculated prefix, e.g. Byte-> kBytes
@@ -36,7 +36,7 @@ std::string NumberOfBytesToString(double value,const char*suffix) {
3636
suffix="";
3737
}
3838
snprintf(bufStr,sizeof(bufStr)-1,"%.03lf %s%s",scaledValue,prefixes[prefixIndex],suffix);
39-
return std::string(bufStr);
39+
return std::string(bufStr);
4040
}
4141

4242

@@ -58,7 +58,7 @@ class ConsumerStats: public Consumer {
5858
if (monitoringEnabled) {
5959
// todo: support for long long types
6060
// https://alice.its.cern.ch/jira/browse/FLPPROT-69
61-
61+
6262
monitoringCollector->send(counterBlocks, "readout.Blocks");
6363
monitoringCollector->send(counterBytesTotal, "readout.BytesTotal");
6464
monitoringCollector->send(counterBytesDiff, "readout.BytesInterval");
@@ -67,11 +67,11 @@ class ConsumerStats: public Consumer {
6767
counterBytesDiff=0;
6868
}
6969
}
70-
71-
72-
public:
70+
71+
72+
public:
7373
ConsumerStats(ConfigFile &cfg, std::string cfgEntryPoint):Consumer(cfg,cfgEntryPoint) {
74-
74+
7575
cfg.getOptionalValue(cfgEntryPoint + ".monitoringEnabled", monitoringEnabled, 0);
7676
if (monitoringEnabled) {
7777
cfg.getOptionalValue(cfgEntryPoint + ".monitoringUpdatePeriod", monitoringUpdatePeriod, 10);
@@ -83,7 +83,7 @@ class ConsumerStats: public Consumer {
8383

8484
t.reset(monitoringUpdatePeriod*1000000);
8585
}
86-
86+
8787
counterBytesTotal=0;
8888
counterBytesHeader=0;
8989
counterBlocks=0;
@@ -113,13 +113,13 @@ class ConsumerStats: public Consumer {
113113

114114
// printf("Stats: got %p (%d)\n",b,b.use_count());
115115
if (monitoringEnabled) {
116-
// todo: do not check time every push() if it goes fast...
116+
// todo: do not check time every push() if it goes fast...
117117
if (t.isTimeout()) {
118118
publishStats();
119119
t.increment();
120120
}
121121
}
122-
122+
123123
return 0;
124124
}
125125
};

0 commit comments

Comments
 (0)