How are akka actors implemented on underlying threads?

前端 未结 3 1234
悲&欢浪女
悲&欢浪女 2021-02-01 23:02

Given an execution context and a thread pool, how are akka/scala actors scheduled/implemented on that?

3条回答
  •  攒了一身酷
    2021-02-01 23:44

    On 'I was looking into something more like say you are given a thread pool of 10 threads and 50 actors spun off of it, how are so many actors handled by a batch of 10 threads?'

    The exact behavior depends on the dispatcher and configuration. However, most dispatchers do basically something like this:

    • Select an actor which has a non-empty mailbox
    • That 'actor' is then dispatched to run on the executor
    • Where messages are dequed and processed.
      • When possible, a few messages are dequed and processed one after another
      • After processing some messages (or none left), another actor is picked, to prevent starvation. (throughput parameter)
    • Rise and repeat

提交回复
热议问题