D-Bus 1.15.12
|
implementation details for DBusTimeout More...
Data Structures | |
struct | DBusTimeout |
Internals of DBusTimeout. More... | |
struct | DBusTimeoutList |
DBusTimeoutList implementation details. More... | |
Typedefs | |
typedef struct DBusTimeoutList | DBusTimeoutList |
Opaque data type representing a list of timeouts and a set of DBusAddTimeoutFunction/DBusRemoveTimeoutFunction. | |
typedef dbus_bool_t(* | DBusTimeoutHandler) (void *data) |
function to run when the timeout is handled | |
Functions | |
DBusTimeout * | _dbus_timeout_new (int interval, DBusTimeoutHandler handler, void *data, DBusFreeFunction free_data_function) |
Creates a new DBusTimeout, enabled by default. | |
DBusTimeout * | _dbus_timeout_ref (DBusTimeout *timeout) |
Increments the reference count of a DBusTimeout object. | |
void | _dbus_timeout_unref (DBusTimeout *timeout) |
Decrements the reference count of a DBusTimeout object and finalizes the object if the count reaches zero. | |
void | _dbus_timeout_restart (DBusTimeout *timeout, int interval) |
Change the timeout interval to be interval milliseconds from now (forgetting when the timeout was initially started), and enable it. | |
void | _dbus_timeout_disable (DBusTimeout *timeout) |
Disable the timeout. | |
DBusTimeoutList * | _dbus_timeout_list_new (void) |
Creates a new timeout list. | |
void | _dbus_timeout_list_free (DBusTimeoutList *timeout_list) |
Frees a DBusTimeoutList. | |
dbus_bool_t | _dbus_timeout_list_set_functions (DBusTimeoutList *timeout_list, DBusAddTimeoutFunction add_function, DBusRemoveTimeoutFunction remove_function, DBusTimeoutToggledFunction toggled_function, void *data, DBusFreeFunction free_data_function) |
Sets the timeout functions. | |
dbus_bool_t | _dbus_timeout_list_add_timeout (DBusTimeoutList *timeout_list, DBusTimeout *timeout) |
Adds a new timeout to the timeout list, invoking the application DBusAddTimeoutFunction if appropriate. | |
void | _dbus_timeout_list_remove_timeout (DBusTimeoutList *timeout_list, DBusTimeout *timeout) |
Removes a timeout from the timeout list, invoking the application's DBusRemoveTimeoutFunction if appropriate. | |
void | _dbus_timeout_list_toggle_timeout (DBusTimeoutList *timeout_list, DBusTimeout *timeout, dbus_bool_t enabled) |
Sets a timeout to the given enabled state, invoking the application's DBusTimeoutToggledFunction if appropriate. | |
dbus_bool_t | _dbus_timeout_needs_restart (DBusTimeout *timeout) |
Returns whether a timeout needs restart time counting in the event loop. | |
void | _dbus_timeout_restarted (DBusTimeout *timeout) |
Mark timeout as restarted (setting timestamps is responsibility of the event loop). | |
implementation details for DBusTimeout
typedef dbus_bool_t(* DBusTimeoutHandler) (void *data) |
function to run when the timeout is handled
Definition at line 43 of file dbus-timeout.h.
Opaque data type representing a list of timeouts and a set of DBusAddTimeoutFunction/DBusRemoveTimeoutFunction.
Automatically handles removing/re-adding timeouts when the DBusAddTimeoutFunction is updated or changed. Holds a reference count to each timeout.
Definition at line 40 of file dbus-timeout.h.
DBUS_PRIVATE_EXPORT void _dbus_timeout_disable | ( | DBusTimeout * | timeout | ) |
Disable the timeout.
Note that you should use _dbus_connection_toggle_timeout_unlocked() etc. instead, if the timeout is passed out to an application main loop. i.e. you can't use this function in the D-Bus library, it's only used in the message bus daemon implementation.
timeout | the timeout |
enabled | TRUE if timeout should be enabled. |
Definition at line 161 of file dbus-timeout.c.
References DBusTimeout::enabled, and FALSE.
dbus_bool_t _dbus_timeout_list_add_timeout | ( | DBusTimeoutList * | timeout_list, |
DBusTimeout * | timeout | ||
) |
Adds a new timeout to the timeout list, invoking the application DBusAddTimeoutFunction if appropriate.
timeout_list | the timeout list. |
timeout | the timeout to add. |
Definition at line 314 of file dbus-timeout.c.
References _dbus_list_append(), _dbus_list_remove_last(), _dbus_timeout_ref(), _dbus_timeout_unref(), DBusTimeoutList::add_timeout_function, FALSE, NULL, DBusTimeoutList::timeout_data, DBusTimeoutList::timeouts, and TRUE.
Referenced by _dbus_connection_add_timeout_unlocked(), and _dbus_server_add_timeout().
void _dbus_timeout_list_free | ( | DBusTimeoutList * | timeout_list | ) |
Frees a DBusTimeoutList.
timeout_list | the timeout list. |
Definition at line 217 of file dbus-timeout.c.
References _dbus_list_clear_full(), _dbus_timeout_list_set_functions(), _dbus_timeout_unref(), dbus_free(), NULL, and DBusTimeoutList::timeouts.
Referenced by _dbus_connection_new_for_transport(), _dbus_server_finalize_base(), and _dbus_server_init_base().
DBusTimeoutList * _dbus_timeout_list_new | ( | void | ) |
Creates a new timeout list.
Returns NULL if insufficient memory exists.
Definition at line 200 of file dbus-timeout.c.
References dbus_new0, and NULL.
Referenced by _dbus_connection_new_for_transport(), and _dbus_server_init_base().
void _dbus_timeout_list_remove_timeout | ( | DBusTimeoutList * | timeout_list, |
DBusTimeout * | timeout | ||
) |
Removes a timeout from the timeout list, invoking the application's DBusRemoveTimeoutFunction if appropriate.
timeout_list | the timeout list. |
timeout | the timeout to remove. |
Definition at line 344 of file dbus-timeout.c.
References _dbus_assert_not_reached, _dbus_list_remove(), _dbus_timeout_unref(), NULL, DBusTimeoutList::remove_timeout_function, DBusTimeoutList::timeout_data, and DBusTimeoutList::timeouts.
Referenced by _dbus_connection_remove_timeout_unlocked(), and _dbus_server_remove_timeout().
dbus_bool_t _dbus_timeout_list_set_functions | ( | DBusTimeoutList * | timeout_list, |
DBusAddTimeoutFunction | add_function, | ||
DBusRemoveTimeoutFunction | remove_function, | ||
DBusTimeoutToggledFunction | toggled_function, | ||
void * | data, | ||
DBusFreeFunction | free_data_function | ||
) |
Sets the timeout functions.
This function is the "backend" for dbus_connection_set_timeout_functions().
timeout_list | the timeout list |
add_function | the add timeout function. |
remove_function | the remove timeout function. |
toggled_function | toggle notify function, or NULL |
data | the data for those functions. |
free_data_function | the function to free the data. |
Definition at line 243 of file dbus-timeout.c.
References _dbus_list_foreach(), _dbus_list_get_first_link(), _dbus_list_get_next_link, DBusTimeoutList::add_timeout_function, DBusList::data, FALSE, NULL, DBusTimeoutList::remove_timeout_function, DBusTimeoutList::timeout_data, DBusTimeoutList::timeout_free_data_function, DBusTimeoutList::timeout_toggled_function, DBusTimeoutList::timeouts, and TRUE.
Referenced by _dbus_timeout_list_free(), dbus_connection_set_timeout_functions(), and dbus_server_set_timeout_functions().
void _dbus_timeout_list_toggle_timeout | ( | DBusTimeoutList * | timeout_list, |
DBusTimeout * | timeout, | ||
dbus_bool_t | enabled | ||
) |
Sets a timeout to the given enabled state, invoking the application's DBusTimeoutToggledFunction if appropriate.
timeout_list | the timeout list. |
timeout | the timeout to toggle. |
enabled | TRUE to enable |
Definition at line 366 of file dbus-timeout.c.
References DBusTimeout::enabled, NULL, DBusTimeoutList::timeout_data, and DBusTimeoutList::timeout_toggled_function.
Referenced by _dbus_connection_toggle_timeout_unlocked(), and _dbus_server_toggle_timeout().
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_timeout_needs_restart | ( | DBusTimeout * | timeout | ) |
Returns whether a timeout needs restart time counting in the event loop.
timeout | the DBusTimeout object |
Definition at line 389 of file dbus-timeout.c.
References DBusTimeout::needs_restart.
DBUS_PRIVATE_EXPORT DBusTimeout * _dbus_timeout_new | ( | int | interval, |
DBusTimeoutHandler | handler, | ||
void * | data, | ||
DBusFreeFunction | free_data_function | ||
) |
Creates a new DBusTimeout, enabled by default.
interval | the timeout interval in milliseconds. |
handler | function to call when the timeout occurs. |
data | data to pass to the handler |
free_data_function | function to be called to free the data. |
Definition at line 66 of file dbus-timeout.c.
References dbus_new0, DBusTimeout::enabled, FALSE, DBusTimeout::free_handler_data_function, DBusTimeout::handler, DBusTimeout::handler_data, DBusTimeout::interval, DBusTimeout::needs_restart, NULL, DBusTimeout::refcount, and TRUE.
Referenced by _dbus_pending_call_new_unlocked().
DBusTimeout * _dbus_timeout_ref | ( | DBusTimeout * | timeout | ) |
Increments the reference count of a DBusTimeout object.
timeout | the timeout object. |
Definition at line 97 of file dbus-timeout.c.
References DBusTimeout::refcount.
Referenced by _dbus_timeout_list_add_timeout().
DBUS_PRIVATE_EXPORT void _dbus_timeout_restart | ( | DBusTimeout * | timeout, |
int | interval | ||
) |
Change the timeout interval to be interval milliseconds from now (forgetting when the timeout was initially started), and enable it.
This function is only valid when used in conjunction with DBusLoop: it can be used in the message bus daemon implementation or in unit tests, but it cannot be used in conjunction with an application main loop.
timeout | the timeout |
interval | the new interval |
Definition at line 140 of file dbus-timeout.c.
References _dbus_assert, DBusTimeout::enabled, DBusTimeout::interval, DBusTimeout::needs_restart, and TRUE.
DBUS_PRIVATE_EXPORT void _dbus_timeout_restarted | ( | DBusTimeout * | timeout | ) |
Mark timeout as restarted (setting timestamps is responsibility of the event loop).
timeout | the DBusTimeout object |
Definition at line 401 of file dbus-timeout.c.
References FALSE, and DBusTimeout::needs_restart.
DBUS_PRIVATE_EXPORT void _dbus_timeout_unref | ( | DBusTimeout * | timeout | ) |
Decrements the reference count of a DBusTimeout object and finalizes the object if the count reaches zero.
timeout | the timeout object. |
Definition at line 111 of file dbus-timeout.c.
References _dbus_assert, dbus_free(), dbus_timeout_set_data(), DBusTimeout::free_handler_data_function, DBusTimeout::handler_data, NULL, and DBusTimeout::refcount.
Referenced by _dbus_timeout_list_add_timeout(), _dbus_timeout_list_free(), and _dbus_timeout_list_remove_timeout().