Bukkit scheduler - what are the intended use cases?

Discussion in 'Plugin Development' started by akrieger, May 3, 2011.

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

    akrieger

    So, I know that Bukkit/CraftBukkit has this scheduler, and you can use it to schedule either asynch or synchronous tasks, repeatedly or one-time, etc. My question is, what is the intended use case? Should event listeners be delegated to simply doing everything in a delayed task? I remember reading on the wiki, in a page that might have been outdated, that most API calls need/should be called in a synchronous task, since events are fired asynchronously. However, what if you need to change the source/destination of movement events? In that case you have to do things 'inline.'
    If there is, in fact, a danger with event listeners being asynch, but needing to do things with the API that can result in races, then what can be done? I know problems can occur - my plugin (Nethrar) occasionally runs into a situation where a player is marked as being "in a vehicle" (isInVehicle() returns true), but then either the Vehicle is null (getVehicle() returns null) or the vehicle's Location is null. Either there's a race, or there's Player object state corruption occuring somewhere.
    Just to throw out an idea, could there be a way to register event listeners as "synchronous" or "asynchronous? Maybe certain events can only have asynch listeners installed (like PlayerMove, for example, cause those happen *so often*)? Not sure if this would fix certain problems, or reduce the number of conflicts that can occur in the future, but as plugins and the server get more and more complicated, this could become more and more of an issue.
     
Thread Status:
Not open for further replies.

Share This Page