Usage of Asynchronous

Discussion in 'Spigot Plugin Development' started by Hunky524, May 26, 2016.

  1. As this is a discussion forum about Spigot development, I thought I should create this thread here. I know spigot allows programmers to schedule async tasks. I know async tasks are able to run at the same time as normal Spigot operations on different CPU threads. I could see how this would have huge performance improvements in large scale applications. What viable applications do asynchronous tasks have for Spigot. I was looking on the Spigot API and it says "Asynchronous tasks should never access any API in Bukkit.". If you can't access the Bukkit API, is the only purpose of asynchronous tasks to calculate large operations outside of your main server functions so that it doesn't lag your server, or are there other applications you can use it for?
  2. Anything which will require waiting until a response, e.g. database or http queries. If it takes up cpu time, it takes up main thread time which bukkit already uses extensively.
  3. Ok, but you cannot use any of the Spigot/Bukkit API in asynchronous tasks correct? Or can you?
  4. You shouldn't try to directly, however you can call a synchronous task in an async task to run something in the Bukkit API.
    • Agree Agree x 1