Inkscape
Vector Graphics Editor
|
#include <timer.h>
Public Member Functions | |
ExpirationTimer (Extension *in_extension) | |
Create a new expiration timer. More... | |
virtual | ~ExpirationTimer () |
Deletes a ExpirationTimer . More... | |
void | touch () |
Touches the timer to extend the length before it expires. More... | |
void | lock () |
void | unlock () |
Static Public Member Functions | |
static void | set_timeout (long in_seconds) |
Set the timeout variable. More... | |
Private Member Functions | |
bool | expired () const |
Check to see if the timer has expired. More... | |
Static Private Member Functions | |
static bool | idle_func () |
This function goes in the idle loop to find expired extensions. More... | |
static bool | timer_func () |
A timer function to set up the idle function. More... | |
Private Attributes | |
int | locked |
Is this extension locked from being unloaded? More... | |
ExpirationTimer * | next |
Next entry in the list. More... | |
Glib::DateTime | expiration |
When this timer expires. More... | |
Extension * | extension |
What extension this function relates to. More... | |
Static Private Attributes | |
static ExpirationTimer * | timer_list = nullptr |
Circularly linked list of all timers. More... | |
static ExpirationTimer * | idle_start = nullptr |
Which timer was on top when we started the idle loop. More... | |
static long | timeout = 240 |
What the current timeout is (in seconds) More... | |
static bool | timer_started = false |
Has the timer been started? More... | |
Inkscape::Extension::ExpirationTimer::ExpirationTimer | ( | Extension * | in_extension | ) |
Create a new expiration timer.
in_extension | Which extension this timer is related to |
This function creates the timer, and sets the time to the current time, plus what ever the current timeout is. Also, if this is the first timer extension, the timer is kicked off. This function also sets up the circularly linked list of all the timers.
Definition at line 37 of file timer.cpp.
References expiration, next, timeout, timer_func(), timer_list, and timer_started.
|
virtual |
Deletes a ExpirationTimer
.
The most complex thing that this function does is remove the timer from the circularly linked list. If this is the only entry in the list that is easy, otherwise all the entries must be found, and this one removed from the list.
Definition at line 67 of file timer.cpp.
References idle_start, next, and timer_list.
|
private |
Check to see if the timer has expired.
Checks the time against the current time.
Definition at line 123 of file timer.cpp.
References current, expiration, and locked.
Referenced by idle_func().
|
staticprivate |
This function goes in the idle loop to find expired extensions.
This function first insures that there is a timer list, and then checks to see if the one on the top of the list has expired. If it has expired it unloads the module. By unloading the module, the timer gets deleted (happens in the unload function). If the list is no empty, the function returns that it should be dequeued and sets the timer_started
variable so that the timer will be reissued when a timer is added. If there is entries left, but the next one is where this function started, then the timer is set up. The timer will then re-add the idle loop function when it runs.
Definition at line 147 of file timer.cpp.
References expired(), extension, idle_start, next, Inkscape::Extension::Extension::set_state(), Inkscape::Extension::Extension::STATE_UNLOADED, timeout, timer_func(), timer_list, and timer_started.
Referenced by timer_func().
|
inline |
|
inlinestatic |
|
staticprivate |
A timer function to set up the idle function.
This function sets up the idle loop when it runs. The idle loop is the one that unloads all the extensions.
Definition at line 191 of file timer.cpp.
References idle_func(), idle_start, and timer_list.
Referenced by ExpirationTimer(), and idle_func().
void Inkscape::Extension::ExpirationTimer::touch | ( | ) |
Touches the timer to extend the length before it expires.
Basically it adds more time to the timer. One thing that is kinda tricky is that it adds half the time remaining back into the timer. This allows for some extensions that are used regularly to having extended expiration times. So, in the end, they stay loaded longer. Extensions that are only used once will expire at a standard rate set by timeout
.
Definition at line 106 of file timer.cpp.
References current, expiration, and timeout.
|
inline |
|
private |
When this timer expires.
Definition at line 41 of file timer.h.
Referenced by ExpirationTimer(), expired(), and touch().
|
private |
What extension this function relates to.
Definition at line 43 of file timer.h.
Referenced by idle_func().
|
staticprivate |
Which timer was on top when we started the idle loop.
Definition at line 30 of file timer.h.
Referenced by idle_func(), timer_func(), and ~ExpirationTimer().
|
private |
|
private |
Next entry in the list.
Definition at line 39 of file timer.h.
Referenced by ExpirationTimer(), idle_func(), and ~ExpirationTimer().
|
staticprivate |
What the current timeout is (in seconds)
Definition at line 32 of file timer.h.
Referenced by ExpirationTimer(), idle_func(), set_timeout(), and touch().
|
staticprivate |
Circularly linked list of all timers.
Definition at line 28 of file timer.h.
Referenced by ExpirationTimer(), idle_func(), timer_func(), and ~ExpirationTimer().
|
staticprivate |
Has the timer been started?
Definition at line 34 of file timer.h.
Referenced by ExpirationTimer(), and idle_func().