我有 2 个进程,一个进程将数据包流式传输到另一个进程,直到内部中断停止该进程(发送的进程)。我希望有一种机制,其他进程可以接收,直到此通道上有任何消息要接收。
除了将停止命令也作为消息传输之外,还有什么方法可以做到这一点?我不希望将完成/中断作为另一条消息发送,因为在某些情况下中断可能会杀死发送方进程。
if (world.rank() != 0) {
while (!interrupt())
world.send(ROOT, ID, a, bufferSize);
// I prefer not to send finish/interrupt as another message
}
else {
while (/*there is any packet to be received*/)
world.recv(boost::mpi::any_source, ID, a, bufferSize);
}