+ Reply to Thread
Results 1 to 7 of 7
Like Tree1Likes
  • 1 Post By the_real_seebs

Thread: LibCron: Timers handled for you.

  1. #1
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default LibCron: Timers handled for you.

    Sick of writing an update hook that does nothing but check whether it's been a second since you ran your update hook yet?

    Library.LibCron.recurring(interval, function, ...)
    Library.LibCron.create(interval, function, ...)

    The .create call makes a one-shot.

    Both return a tag which can be used to .delete(tag) or to .snooze(tag, seconds).

    If you have an update hook that's just doing something every second or whatever, please consider using libcron instead to reduce the number of update hooks floating around.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

  2. #2
    Plane Touched
    Join Date
    Feb 2012
    Posts
    228

    Default

    I might use this.

    Any chance to get this released without the LibGetOpt stuff?

    Does it work well with subsecond precision? What would happen if you set a recurring task with interval of 0 seconds?

  3. #3
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    ooh, 0 seconds would be bad, because the event would end up being called again. I should fix that. Easiest fix is just to use now + event.secs rather than event.stamp + event.secs. Then that won't be < now.

    I suppose I could probably debundle this from its command line interface. It's just that that basically means splitting it into two addons.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

  4. #4
    Plane Touched
    Join Date
    Feb 2012
    Posts
    228

    Default

    math.max(now, event.stamp + event.secs) would take care of negative values too and lose less precision

  5. #5
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    Quote Originally Posted by Baanano View Post
    math.max(now, event.stamp + event.secs) would take care of negative values too and lose less precision
    Hmm, true. 'k. Doing that.

    Is there a particular problem caused by the embedded libgetopt, or is it just that it's Extra Baggage?
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

  6. #6
    Plane Touched
    Join Date
    Feb 2012
    Posts
    228

    Default

    Extra baggage as you say.

    More than anything it's that I wouldn't want the player to be able to delete the task that easily. They could do it through /script though

    Some ideas on minor features:

    1) A way to prevent tasks from being deleted, so they can only be snoozed / paused.

    2) A way to set the first execution time as an absolute timestamp instead of an offset of the current timestamp.

    3) A snooze variant to pause/resume execution instead of just delaying it

    4) Statistics on number of executions, total time used, average time used. This could be turned off if an addon can't afford the extra delay.

    5) A GUI to see tasks, their statistics and pause/resume/delete them. Snooze could be included too, but I don't like textfields :P This would be a separate addon (LibCronManager?) so you can move there the LibGetOpt stuff and have LibCron as a standalone library. I know you don't like writing UIs, so I could write this if you want
    Last edited by Baanano; 04-01-2012 at 12:43 PM.

  7. #7
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    Not sure about a way to prevent tasks from being deleted. I would actually sorta like a way to make tasks persistent, except that this turns out to be Very Hard unless they're defined by code snippets.

    Absolute time I could probably do -- heck, if I'm willing to assume no one will run the game for more than 20 years without a /reloadui, I can do it automatically by assuming that 9-digit time numbers are absolute times. :P

    Pause/unpause makes sense.

    Performance, you can already do by grabbing LibPerfORate and having it wrap your callback.

    I think I may make the GetOpt thing an optional requirement, and simply only call it if GetOpt is around.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts