Another way to do this?

Discussion in 'Plugin Development' started by amitlin14, Jun 20, 2013.

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

    amitlin14

    ok so im making a profiling system, it takes the player's info and updates it into a MySQL database, right now im using a Profile class to save some info it gets from other plugins using metadata. The profile class is constructed when a player logs in for the first time every 30 minutes, meaning, every 30 minutes all the profiles that are cached are flushed, and then the cycle restarts.

    I want to use a repeating Async task for this, but i cant, because when i flush the cache, i only flush those who have logged in in the past 30 minutes, but are no longer online, that way i dont need to readd those who are online, i simply update their info, using metadata, inside the Async task. Because i must use the bukkit api, i cant use an async repeating task, that said, it doesnt mean i cant use an Asnc task, it just means i cant use a repeating one, at least i think so. What i have in mind this:

    When the server starts, open up an async thread, and keep it active untill server shutdown. When a player logs in, his info is updated into a profile class, and when he logs out, i simply update the info, and then run the task inside the new, active thread, that way i dont have to construct a new thread every time i wanna save on player quit.

    Is this possible, or is my view on threads and tasks completely wrong?
     
  2. Offline

    microgeek

    You can spawn a Sync task from an Async task.
     
  3. Offline

    amitlin14

    is it any different from just using a repeating sync task?
     
Thread Status:
Not open for further replies.

Share This Page