runTaskSoon() Function in BukkitScheduler

Discussion in 'Bukkit Discussion' started by krisdestruction, Jul 25, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    krisdestruction

    Hey guys,

    I feel that the bukkit API should create a runTaskSoon(Plugin plugin,Runnable runnable) function to allow developers to schedule something synchronously and not time out the server. Essentially what this function would do is put the Runnable in a queue and in the background, it would use all idle time between ticks to try to accomplish as many tasks as possible. On the scheduler side, it would continue popping and running the task until the remaining 1/20 seconds that bukkit code execution is used up.

    While the scheduler cannot guarantee 20 TPS on servers, it can help encourage devs to schedule smaller synchronous tasks that are not time critical (eg. WorldEditing 1000 blocks, separating each block into 1 task). I believe that BukkitRunnables don't have too much overhead as seen from the Scheduler Programming tutorial:
    Any thoughts on the matter?
     
  2. Offline

    Maximvdw

    Thats not really how threading works :/,.. won't see much use in it, better to use async tasks doing calculations and synchronize them again when needed.
     
  3. Offline

    krisdestruction

    I'm not trying to achieve threading, and I do know how threading works. I'm just saying that for something like a WorldEdit of 10 Billion blocks, it's possible to split this between different ticks automatically. It also doesn't help that most of the bukkit API is not thread-safe.
     
Thread Status:
Not open for further replies.

Share This Page