![]() |
![]() |
![]() |
GIO Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties | Signals |
GPeriodic; GPeriodic * g_periodic_new (guint hz
,gint priority
); guint g_periodic_get_hz (GPeriodic *periodic
); gint g_periodic_get_priority (GPeriodic *periodic
); void (*GPeriodicTickFunc) (GPeriodic *periodic
,guint64 timestamp
,gpointer user_data
); guint g_periodic_add (GPeriodic *periodic
,GPeriodicTickFunc callback
,gpointer user_data
,GDestroyNotify notify
); void g_periodic_remove (GPeriodic *periodic
,guint tag
); void g_periodic_block (GPeriodic *periodic
); void g_periodic_unblock (GPeriodic *periodic
); void (*GPeriodicRepairFunc) (GPeriodic *periodic
,gpointer user_data
); void g_periodic_damaged (GPeriodic *periodic
,GPeriodicRepairFunc callback
,gpointer user_data
,GDestroyNotify notify
);
"hz" guint : Read / Write / Construct Only "priority" gint : Read / Write / Construct Only
GPeriodic is a periodic event clock that fires a configurable number of times per second and is capable of being put into synch with an external time source.
A number of GPeriodicTickFuncs are registered with
g_periodic_add()
and are called each time the clock "ticks".
The tick functions can report "damage" (ie: updates that need to be performed) that are handled in a "repair" phase that follows all the tick functions having been run. It is also possible to report damage while the clock is not running, in which case the rate of repairs will be rate limited as if the clock were running.
GPeriodic is intended to be used as a paint clock for managing geometry updates and painting of windows.
GPeriodic * g_periodic_new (guint hz
,gint priority
);
Creates a new GPeriodic clock.
The created clock is attached to the thread-default main context in
effect at the time of the call to this function. See
g_main_context_push_thread_default()
for more information.
Due to the fact that GMainContext is only accurate to the nearest millisecond, the frequency can not meaningfully get too close to 1000. For this reason, it is arbitrarily bounded at 120.
|
the frequency of the new clock in Hz (between 1 and 120) |
|
the GSource priority to run at |
Returns : |
a new GPeriodic |
Since 2.28
guint g_periodic_get_hz (GPeriodic *periodic
);
Gets the frequency of the clock.
|
a GPeriodic clock |
Returns : |
the frquency of the clock, in Hz |
Since 2.28
gint g_periodic_get_priority (GPeriodic *periodic
);
Gets the GSource priority of the clock.
|
a GPeriodic clock |
Returns : |
the priority level |
Since 2.28
void (*GPeriodicTickFunc) (GPeriodic *periodic
,guint64 timestamp
,gpointer user_data
);
The signature of the callback function that is called when the GPeriodic clock ticks.
The timestamp
parameter is equal for all callbacks called during a
particular tick on a given clock.
|
the GPeriodic clock that is ticking |
|
the timestamp at the time of the tick |
|
the user data given to g_periodic_add()
|
Since 2.28
guint g_periodic_add (GPeriodic *periodic
,GPeriodicTickFunc callback
,gpointer user_data
,GDestroyNotify notify
);
Request periodic calls to callback
to start. The periodicity of the
calls is determined by the 'hz' property.
This function may not be called from a handler of the repair signal, but it is perfectly reasonable to call it from a handler of the tick signal.
The callback may be cancelled later by using g_periodic_remove()
on
the return value of this function.
|
a GPeriodic clock |
|
a GPeriodicTickFunc function |
|
data for callback
|
|
for freeing user_data when it is no longer needed
|
Returns : |
a non-zero tag identifying this callback |
Since 2.28
void g_periodic_remove (GPeriodic *periodic
,guint tag
);
Reverse the effect of a previous call to g_periodic_start()
.
tag
is the ID returned by that function.
This function may not be called from a handler of the repair signal, but it is perfectly reasonable to call it from a handler of the tick signal.
|
a GPeriodic clock |
|
the ID of the callback to remove |
Since 2.28
void g_periodic_block (GPeriodic *periodic
);
Temporarily blocks periodic
from running in order to bring it in
synch with an external time source.
This function must be called from a handler of the "repair" signal.
If this function is called, emission of the tick signal will be
suspended until g_periodic_unblock()
is called an equal number of
times. Once that happens, the "tick" signal will run immediately and
future "tick" signals will be emitted relative to the time at which
the last call to g_periodic_unblock()
occured.
|
a GPeriodic clock |
Since 2.28
void g_periodic_unblock (GPeriodic *periodic
);
Reverses the effect of a previous call to g_periodic_block()
.
If this call removes the last block, the tick signal is immediately run. The repair signal may also be run if the clock is marked as damaged.
This function may not be called from handlers of any signal emitted
by periodic
.
|
a GPeriodic clock |
Since 2.28
void (*GPeriodicRepairFunc) (GPeriodic *periodic
,gpointer user_data
);
The signature of the callback function that is called during the
repair phase when damaged was reported using g_periodic_damaged()
.
|
the GPeriodic clock that the damage was reported to |
|
the user data given to g_periodic_damaged()
|
Since 2.28
void g_periodic_damaged (GPeriodic *periodic
,GPeriodicRepairFunc callback
,gpointer user_data
,GDestroyNotify notify
);
Report damage and schedule callback
to be called during the next
repair phase. Multiple registrations result in multiple invocations,
so you should track for yourself if you are already registered.
You may not call this function during the repair phase.
|
a GPeriodic clock |
|
a GPeriodicRepairFunc |
|
data for callback
|
|
for freeing user_data when it is no longer needed
|
Since 2.28
"hz"
property"hz" guint : Read / Write / Construct Only
rate (in Hz) at which the 'tick' signal is emitted.
Allowed values: [1,120]
Default value: 1
"priority"
property"priority" gint : Read / Write / Construct Only
the GSource priority level to run at.
Default value: 0