Resource TaskChain - Proper Async Operations and more!

Discussion in 'Spigot Plugin Development' started by Aikar, Oct 30, 2016.

  1. Random hiccups happen, so 19.98 is perfectly normal for any server.

    Sure, https://paypal.me/empireminecraft - this is my personal company, makes it easier for me to track extra income to pay the taxes on it. (donation's are only tax-free if it's to a non profit company :p)
     
  2. foncused

    Moderator Patron

    Yeah I figured as much but thought I would ask anyway since I only noticed the drop immediately following the quit event (and as an extension was then thinking what would happen if a bunch of people leave at the same time). :p
    I know such a small drop is nothing to really worry about - my OCD more or less wanted to know. Thanks again!
    Thanks, sir.
     
  3. @Aikar Does this work for bungeecord plugins as well?
     
  4. electronicboy

    IRC Staff

    Bungeecord doesn't have the concept of a main thread, so taskchain is pretty much irrelevant for it
     
    • Informative Informative x 1
  5. Been a while, still very useful to use, so bump!
     
    • Agree Agree x 2
  6. What's different with CompletableFuture ?
     
  7. MiniDigger

    Supporter

    Taskchain utilises callbacks like futures, but the point of taskchain is to easily switch between the main thread and an async thread. Imagine calling a web-api async, then doing something with the Bukkit API with the result and then posting something to a web api async again. Taskchain helps you to not get lost in callback hell
     
  8. CompletableFuture also provides switching between threads.
     
  9. TaskChain also makes it much easier to return to the main thread later, removes a decent amount of fluff and callback hell potential. If you prefer CompletableFutures that's fine, but it's designed around entering and exiting the main thread without having to use the clunkier methods Bukkit provides. Bukkit doesn't exactly make it easy to avoid callback hell, there's been no update to the scheduler API in a long time.
     
  10. There was the proposed Consumer syntax availability that was merged a couple of months ago. Unrelated to switching around threads in a threaded environment, but figured I'd point this out.
     
    • Informative Informative x 1
    • Useful Useful x 1
  11. Yeah, that was nice, good point. My main issue lies with BukkitScheduler#callSyncMethod requiring a decent bit of boilerplate to handle. Honestly, changing the return from a Future to a CompletableFuture would make TaskChain largely unnecessary, though I do also need its other features from time to time.