Return of the Scala Actor?

Yes, indeed. One such existing abstraction is ExecutionContext, for submitting tasks to some sort of executor (typically a threadpool).

Where we are currently lacking an abstraction is something for scheduling timers. The JDK offers ScheduledExecutorServce, but it is heavy-weight and not cross-platform (see also Scala ExecutionContext vs JDK ExecutorService).

So instead in Cats Effect we have the simpler Scheduler, which is sufficient and can be implemented on all platforms. It would be excellent to see an abstraction like this in the Scala stdlib, alongside ExecutionContext. Moreover, just as many libraries today are configurable via an implicit ec: ExecutionContext parameter, they should also expose an implicit sched: Scheduler if they need timer capabilities.

Besides the ability to submit tasks and schedule timers, an event loop should also offer some capability to poll for I/O-readiness. While an abstraction in this space would also be valuable, it’s not yet clear what exactly this should look like. This is what we are currently working on in Cats Effect. Wider participation is very welcome! Kind of difficult to design “shared” abstractions all on your own :grin:

9 Likes