sociomantic-tsunami / swarm

Asynchronous client/node framework library
Boost Software License 1.0
14 stars 26 forks source link

Support alternative task scheduling mechanisms #431

Open joseph-wakeling-frequenz opened 3 years ago

joseph-wakeling-frequenz commented 3 years ago

Swarm and its downstream proto libraries are all currently tightly tied together with ocean's EpollSelectDispatcher. The bulk of the direct usage is in swarm itself (the proto libraries just pass epoll instances into swarm internals, or occasionally use other ocean epoll-based functionality like timers), but the neo protos also make a fair bit of use of the epoll-based Task framework.

The major consequence here is that swarm and the protos are impossible to use with other popular D2 task-scheduling libraries such as vibe.d, to say nothing of the possibility of integration with other languages, where async IO may be managed with other mechanisms and other eventloop controllers.

Given that in practice all the different use-cases will likely be using epoll underneath the hood, it ought to be possible to achieve better integration than this. The question is what the most appropriate mechanism.

Based on a very provisional glance through the codebase there appear to be 3 main use-cases within swarm neo:

Legacy swarm also includes some unregister and setExpiryRegistration calls, while the protos (without checking for neo vs. legacy) similarly seem to use just {un}register and Task.getThis() calls.

This all feels high-level enough that it ought to be possible to abstract it away from EpollSelectDispatcher specifics, but that begs some questions:

Thoughts, ideas, and feedback all welcome.