Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有/我怎样才能保证发送到邮箱处理器的消息的到达顺序
也就是说,如果我这样做了
agent.post(msg1) agent.post(msg2)
我如何确定在代理的处理循环中,消息将按顺序接收?
他们是。正如您可能猜到的那样,它的实现Post只是将一个项目添加到队列中(在当前线程上,处于锁定状态),然后发布工作以通知任何等待的代理唤醒并处理它。因此,如果您Post在同一个线程上调用两次,一个接一个,消息按该顺序进入队列。
Post
inbox.Scan(function _ -> None // return an Option)如果您有某种检测顺序的方法,您也可以使用它来查找消息。当然,这是以性能为代价的,因此最好不要排队。
inbox.Scan(function _ -> None // return an Option)