Akka.io:每个演员的线程 [英] Akka.io: Thread per Actor

查看:77
本文介绍了Akka.io:每个演员的线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一项要求异步运行1000次操作,我选择使用Akka。
扭曲Actor Ref执行器,并向ref发送1000条消息。

There is a requirement to run 1 thousand operations asynchoniosly, I've chosen to use Akka. Warpping in Actor Ref executor and sending 1 thousand messages to ref.

我如何确定:


  • 所有一千条消息将以asnc方式分派

  • 每个消息将包含独立的独立线程(由于使用io,因此这是必需的) )。

推荐答案

您可以使用 PinnedDispatcher 保证每个actor一个线程,并且Akka中的所有内容都是异步的,因此可以确保消息是异步的。如果您使用运算符发送消息,则该消息以一劳永逸的方式发送。

You can use the PinnedDispatcher to guarantee one thread per actor, and everything in Akka is async, so you can be guaranteed the messages are async. If you send your messages using the ! operator, the message is sent in a fire-and-forget manner.

有关更多详细信息,请参见

See this for more details.

这篇关于Akka.io:每个演员的线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆