Soletta™ Framework
|
Structure representing a mainloop implementation (hooks). More...
#include <sol-mainloop.h>
Data Fields | |
uint16_t | api_version |
must match SOL_MAINLOOP_IMPLEMENTATION_API_VERSION at runtime. More... | |
void *(* | idle_add )(bool(*cb)(void *data), const void *data) |
Function to be called to register an idler to be dispatched. More... | |
bool(* | idle_del )(void *handle) |
Function to be called to remove an idler to be dispatched. More... | |
int(* | init )(void) |
Function to be called to initialize the mainloop implementation. More... | |
void(* | quit )(void) |
Function to be called to quit the mainloop. More... | |
void(* | run )(void) |
Function to be called to run the mainloop. More... | |
void(* | shutdown )(void) |
Function to be called to shutdown (cleanup) the mainloop implementation. More... | |
void *(* | source_add )(const struct sol_mainloop_source_type *type, const void *data) |
Function to be called to register a mainloop event source. More... | |
void(* | source_del )(void *handle) |
Function to be called to remove mainloop event source. More... | |
void *(* | source_get_data )(const void *handle) |
Function to be called to retrieve mainloop event source internal data. More... | |
void *(* | timeout_add )(uint32_t timeout_ms, bool(*cb)(void *data), const void *data) |
Function to be called to register a timeout to be dispatched. More... | |
bool(* | timeout_del )(void *handle) |
Function to be called to remove a timeout to be dispatched. More... | |
Structure representing a mainloop implementation (hooks).
uint16_t sol_mainloop_implementation::api_version |
must match SOL_MAINLOOP_IMPLEMENTATION_API_VERSION at runtime.
void*(* sol_mainloop_implementation::idle_add)(bool(*cb)(void *data), const void *data) |
Function to be called to register an idler to be dispatched.
This function will register an entry so the pointer cb
will be called with the context data
when there is nothing else to do. This prevents the mainloop from sleeping, as it will keep calling all registered idlers in sequence.
After calling cb
, if it returns true
, then the idle is renewed, otherwise it's automatically cancelled and idle_del
may not be called. Please note that calling sol_idle_del() (and thus idle_del
) from the callback cb
and returning false
is a valid case and must be supported (guard against double-free).
Should exist more than one idle entry, they are executed only once in the order they are registered. At the end it wraps back to the first element and continues.
This function must return an internal handle that will represent the idle. It will be given to sol_idle_del() in order to cancel it before it fires.
This function will be called whenever sol_idle_add() is called.
Must not be NULL.
bool(* sol_mainloop_implementation::idle_del)(void *handle) |
Function to be called to remove an idler to be dispatched.
This function receives the handle returned by sol_idle_add() (and thus idle_add
), deleting it so the registered callback is not called anymore.
This function returns true if idle was successfully deleted.
This function will be called whenever sol_idle_del() is called.
Must not be NULL.
int(* sol_mainloop_implementation::init)(void) |
Function to be called to initialize the mainloop implementation.
This function will be called whenever sol_init() is called.
Must not be NULL.
void(* sol_mainloop_implementation::quit)(void) |
Function to be called to quit the mainloop.
This function will be called whenever sol_quit() or sol_quit_with_code() are called and it should stop the blocking event loop executed by its sibling run
.
Do not cleanup resources here, but in the shutdown
callback.
Must not be NULL.
void(* sol_mainloop_implementation::run)(void) |
Function to be called to run the mainloop.
This function will be called whenever sol_run() is called and it should block until its sibling quit
is called.
Must not be NULL.
void(* sol_mainloop_implementation::shutdown)(void) |
Function to be called to shutdown (cleanup) the mainloop implementation.
This function will be called whenever sol_shutdown() is called.
Must not be NULL.
void*(* sol_mainloop_implementation::source_add)(const struct sol_mainloop_source_type *type, const void *data) |
Function to be called to register a mainloop event source.
This function will register an event source that will be called during the mainloop execution, allowing different mainloops to be integrated. The actual functions to be called are defined in type
.
This function must return an internal handle that will represent the source. It will be given to sol_mainloop_del_source() in order to remove it.
This function will be called whenever sol_mainloop_add_source() is called.
Must not be NULL.
void(* sol_mainloop_implementation::source_del)(void *handle) |
Function to be called to remove mainloop event source.
This function receives the handle returned by sol_mainloop_add_source() (and thus source_add
), deleting it so it is not used anymore.
This function will be called whenever sol_mainloop_del_source() is called.
Must not be NULL.
void*(* sol_mainloop_implementation::source_get_data)(const void *handle) |
Function to be called to retrieve mainloop event source internal data.
This function returns the data
given to source_add
.
This function will be called whenever sol_mainloop_source_get_data() is called.
Must not be NULL.
void*(* sol_mainloop_implementation::timeout_add)(uint32_t timeout_ms, bool(*cb)(void *data), const void *data) |
Function to be called to register a timeout to be dispatched.
This function receives the number of milliseconds since the current time it should wait before calling the given pointer cb
with the context data
.
After calling cb
, if it returns true
, then the timeout is renewed, otherwise it's automatically cancelled and timeout_del
may not be called. Please note that calling sol_timeout_del() (and thus timeout_del
) from the callback cb
and returning false
is a valid case and must be supported (guard against double-free).
This function must return an internal handle that will represent the timeout. It will be given to sol_timeout_del() in order to cancel it before it fires.
This function will be called whenever sol_timeout_add() is called.
Must not be NULL.
bool(* sol_mainloop_implementation::timeout_del)(void *handle) |
Function to be called to remove a timeout to be dispatched.
This function receives the handle returned by sol_timeout_add() (and thus timeout_add
), deleting it so the registered callback is not called anymore.
This function returns true if timeout was successfully deleted.
This function will be called whenever sol_timeout_del() is called.
Must not be NULL.