Skip to content

Commit 00f40ba

Browse files
committed
option for fmqChannelId
1 parent fe70e8a commit 00f40ba

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/testFmqMemory.cxx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ int fmqMemLock = 1; // lock FMQ region
7272
int fmqMemZero = 0; // zero FMQ region
7373
int nLoops = 1; // number of test loops
7474
int memWaitRelease = 0; // amount of time to keep the memory before releasing it
75+
int fmqChannelId = 0; // id used to name the channel. If -1, use PID.
7576

7677
int main(int argc, char* argv[]) {
7778

@@ -105,6 +106,8 @@ int main(int argc, char* argv[]) {
105106
nLoops = atoi(v);
106107
} else if (strcmp(k, "memWaitRelease") == 0) {
107108
memWaitRelease = atoi(v);
109+
} else if (strcmp(k, "fmqChannelId") == 0) {
110+
fmqChannelId = atoi(v);
108111
} else {
109112
printf("unknown option %s\n", k);
110113
return -1;
@@ -140,10 +143,14 @@ int main(int argc, char* argv[]) {
140143
FairMQUnmanagedRegionPtr memoryBuffer = nullptr;
141144
FairMQProgOptions fmqOptions;
142145

143-
log("Create FMQ channel");
146+
if (fmqChannelId == -1) {
147+
fmqChannelId = (int)getpid();
148+
}
149+
auto chname = "readout-test-" + std::to_string(fmqChannelId);
150+
log("Create FMQ channel (%s)", chname.c_str());
144151
// random name: use fair::mq::tools::Uuid()
145-
transportFactory = FairMQTransportFactory::CreateTransportFactory("shmem", "readout-test", &fmqOptions);
146-
sendingChannel = std::make_unique<FairMQChannel>("readout-test", "pair", transportFactory);
152+
transportFactory = FairMQTransportFactory::CreateTransportFactory("shmem", chname, &fmqOptions);
153+
sendingChannel = std::make_unique<FairMQChannel>(chname, "pair", transportFactory);
147154
WAITHERE;
148155

149156
log("Get unmanaged memory (lock=%s, zero=%s)", fmqMemLock ? "yes" : "no", fmqMemZero ? "yes" : "no");

0 commit comments

Comments
 (0)