+ Reply to Thread
Results 1 to 7 of 7

Thread: Library v Watchdog

  1. #1
    Sword of Telara Semele's Avatar
    Join Date
    Mar 2011
    Posts
    872

    Default Library v Watchdog

    Hi, important questions.

    As you know, I'm about to embark on two new libraries. But, I have some concerns. I remember Zorba mentioned something about the Event's fired by a Library would wait on the calling addon to return before proceeding.

    This post is to get some clarification that this is no longer the case, or, at least the time any Addon is handling a Library Event does not count towards the Libraries handler in terms of Watchdog time.

    If the above is true, then this actually defeats the object of libraries cutting down on multiple addons performing identical tasks (such a caching of CPU intensive Inspect.Buff.Detail, for example). And would actually promote that Libraries are not Libraries at all, but copies of files performing the same task per-Addon for each handler. Surely this is the complete opposite of the Watchdogs purpose.

    What I would like to be happening - and it may already be - is that when you call the Event to dispatch it's a call for the API to then process the Event queue after the Library handler has returned, then each Addon is timed as Usual on handling the custom Event queue.

    Anyhow, just my thoughts.
    Rank 76 Guardian Mage

  2. #2
    Sword of Telara DoomSprout's Avatar
    Join Date
    Apr 2011
    Posts
    876

    Default

    There is no fancy queuing of event handlers. When you fire a custom event, each listener will be called in turn, with your library waiting until every handler has completed before it continues.

    Basically, as I understand it, it works like this:

    Code:
    RIFT fires native_event...
    
    foreach handler in native_event_table
    {
        watchdog.resetTimer()
        Utility.Dispatch(handler.function, handler.addonId, handler.info)
    }
    watchdog.stop()
    When you fire a custom event, I believe it's as simple as this:

    Code:
    foreach handler in custom_event_table
    {
        Utility.Dispatch(handler.function, handler.addonId, handler.info)
    }
    Which means the CPU usage stats will be credited to the correct addon (along with error emails) due to the use of Dispatch(), but the watchdog won't be reset as it's only watching CPU time for native events.

    If the watchdog hits its kill time, I don't know whether your library will get the performance warning, or whichever addon is currently being credited with CPU usage by Dispatch(). I would expect it to be the library though
    Last edited by DoomSprout; 09-19-2012 at 04:46 AM.

    Gadgets: Unit Frames and Other Stuff for RIFT

  3. #3
    Sword of Telara Semele's Avatar
    Join Date
    Mar 2011
    Posts
    872

    Default

    Yup, that's what I feared.

    I guess the best way would be to truly embed a Library as just another file then. This would be the only way I see to play with the Watchdog, rather than be efficient.

    Actually, it makes Libraries redundant as a means of across the board optimization. A shame really.
    Last edited by Semele; 09-19-2012 at 05:04 AM.
    Rank 76 Guardian Mage

  4. #4
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    Dispatch() is supposed to start a new watchdog and pause the currently running one, so the called event time doesn't get credited to the caller.
    At least that's how it's supposed to work according to discussions on irc.

    Whether it's really pausing or just resetting is an implementation detail we shouldn't rely on.
    Last edited by Imhothar; 09-19-2012 at 05:41 AM.
    Author of the Imhothar's Bags addon.

  5. #5
    Sword of Telara Semele's Avatar
    Join Date
    Mar 2011
    Posts
    872

    Default

    So, this would mean that the Events should always be passed to Utility.Dispatch().

    If it does pause/reset the Watchdog, this would be perfect.

    Couple of questions, how do I pass the parameters with that, as it can't be called as Utility.Dispatch(Event.Thing(stuff), "addonID", "error things") or can it?

    Also would this mean I actually traverse the Event.table manually rather than calling the Event function?

    Or is the same thing handled internally by the API? If this is true, than disregard the first two questions, although I'd still be interested to know the syntax behind the first question.

    Remember I'm new to Lua in respects to "things I've yet to explore".

    I just want to be 100% sure on the internals of this before I go assuming "this is how it would work in my mind" approach.
    Rank 76 Guardian Mage

  6. #6
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    Calling events returned from Utility.Event.Create() implies a Utility.Dispatch() on each event handler.
    Author of the Imhothar's Bags addon.

  7. #7
    Sword of Telara Semele's Avatar
    Join Date
    Mar 2011
    Posts
    872

    Default

    Quote Originally Posted by Imhothar View Post
    Calling events returned from Utility.Event.Create() implies a Utility.Dispatch() on each event handler.
    Thanks, that saves some time. I guess it would explain why I get no performance warnings for LibSRM.
    Rank 76 Guardian Mage

+ 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