Open Techcable opened 4 years ago
I'm leaning towards making the scheduler just a simple wrapper around the JDK's ScheduledExecutorService. It should be per-plugin so plugins don't interfere with each others tasks. I assume wasted threads for plugins that don't use the scheduler isn't a problem.
There is technically potential for API if a plugin uses a lot of blocking tasks but those plugins are kind of dumb and I don't know that we should support them.
If we are worried about potential breakage, we should probably just reimplement the whole thing from scratch. Seems like netty does something like this
An idea: Velocity implements its scheduler by using a dedicated executor alongside a single-threaded scheduled executor to fire periodic tasks.
Bungee Scheduler is a little odd. Each plugin gets its own instance of the JDK
Executors.cachedThreadExecutor()
.If you want delayed or periodic tasks, each of the tasks calls
Thread.sleep
and blocks until the appropriate time.Blocking these tasks seems like poor practice. Each scheduled task takes up a dedicated thread, even though it may only run very rarely or for a very short period.
We should consider either