考虑以下例子。一个名为
hello_world actor
的Actor向mirror actor
发送"hello"字符串,然后立即终止。那么从mirror actor
返回的响应world
会发生什么?被忽略了吗?还是留在hello_world actor
的邮箱里?镜子能否知道它的响应丢失了?behavior mirror(event_based_actor* self)
{
return { [=](std::string s){ return "world"; } };
}
void hello_world(event_based_actor* self, const actor& theMirror)
{
self->send(theMirror, "hello");
}
sync_send
(在CAF 0.15中将被request
替换)时,如果接收者不再存在,运行时会生成错误消息。然而,这并没有实现三次握手,即hello_world
可以检测到mirror
是否正确响应,但mirror
无法跟踪响应消息的情况(除非您像@mavam已经说明的那样在顶部实现此操作)。 - neverlord