Skip to content

Commit be7269a

Browse files
ktfdavidrohr
authored andcommitted
DPL: rate limit raw-proxy based on timeframes
1 parent 46c5745 commit be7269a

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

Framework/Core/src/ExternalFairMQDeviceProxy.cxx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,27 @@ DataProcessorSpec specifyExternalFairMQDeviceProxy(char const* name,
411411
}
412412
};
413413

414-
auto runHandler = [dataHandler, device, channel](ProcessingContext&) {
414+
auto runHandler = [dataHandler, device, channel](ProcessingContext& ctx) {
415+
static int64_t consumedTimeframes = 0;
416+
static int64_t sentTimeframes = 0;
417+
auto device = ctx.services().get<RawDeviceService>().device();
418+
if (device->fChannels.count("metric-feedback")) {
419+
// FIXME: only two channels difference
420+
while ((sentTimeframes - consumedTimeframes) > 2) {
421+
FairMQMessagePtr msg;
422+
auto count = device->Receive(msg, "metric-feedback", 0, -1);
423+
if (count <= 0) {
424+
return;
425+
}
426+
assert(msg->GetSize() == 8);
427+
consumedTimeframes = *(int64_t*)msg->GetData();
428+
}
429+
}
430+
415431
FairMQParts parts;
416432
device->Receive(parts, channel, 0);
417433
dataHandler(parts, 0);
434+
sentTimeframes++;
418435
};
419436

420437
return runHandler;

0 commit comments

Comments
 (0)