![]() |
Helixis 1.0
Task Programming API
|
Go to the source code of this file.
Functions | |
| hlx_event_manager * | hlx_event_manager_create () |
| void | hlx_event_manager_destroy (hlx_event_manager *manager) |
| hlx_event_errors | _hlx_event_handler_create_by_hash (_hlx_event_manager *manager, unsigned long id, unsigned int size) |
| void | _hlx_event_handler_destroy (_hlx_event_handler *handler) |
| hlx_event_errors | _hlx_event_register_callback_with_group (_hlx_event_manager *manager, _hlx_event_handler *handler, unsigned long id, _hlx_event_callback *callback, hlx_group_id group_id) |
| _hlx_event_handler * | _hlx_event_return_handler_by_hash (_hlx_event_manager *manager, unsigned long id) |
| hlx_event_errors | hlx_event_notify (hlx_event_manager *manager, unsigned long id, void *event_data) |
Variables | |
| hlx_api | gl_api |
| hlx_scheduler | gl_scheduler |
| hlx_event_manager * | gl_event_manager |
| hlx_event_errors _hlx_event_handler_create_by_hash | ( | _hlx_event_manager * | manager, |
| unsigned long | id, | ||
| unsigned int | size | ||
| ) |
Definition at line 78 of file parallel_events.c.
References _hlx_event_delete_callback(), _hlx_event_return_handler_by_hash(), _hlx_event_handler::callbacks, EV_ERROR_ALREADY_EXISTS, EV_ERROR_MEMORY_EXHAUSTED, EV_ERROR_SUCCESS, _hlx_event_manager::handlers, _hlx_event_handler::hash_code, hlx_api::malloc_entry, _hlx_event_handler::param_size, slist_new(), and slist_new_head().
Referenced by hlx_event_handler_create().
{
_hlx_event_handler* handler;
if (_hlx_event_return_handler_by_hash(manager, id))
return (EV_ERROR_ALREADY_EXISTS);
if ((handler = gl_api.malloc_entry(sizeof(*handler))) == 0)
return (EV_ERROR_MEMORY_EXHAUSTED);
handler->hash_code = id;
if (slist_new(&handler->callbacks, _hlx_event_delete_callback, 0) == 0 || slist_new_head(manager->handlers, handler) == 0)
return (EV_ERROR_MEMORY_EXHAUSTED);
handler->param_size = size;
return (EV_ERROR_SUCCESS);
}
| void _hlx_event_handler_destroy | ( | _hlx_event_handler * | handler | ) |
Definition at line 93 of file parallel_events.c.
References _hlx_event_handler::callbacks, and slist_delete_all_elements().
Referenced by hlx_event_handler_destroy(), and hlx_event_manager_destroy().
{
slist_delete_all_elements(handler->callbacks);
}
| hlx_event_errors _hlx_event_register_callback_with_group | ( | _hlx_event_manager * | manager, |
| _hlx_event_handler * | handler, | ||
| unsigned long | id, | ||
| _hlx_event_callback * | callback, | ||
| hlx_group_id | group_id | ||
| ) |
Definition at line 98 of file parallel_events.c.
References _hlx_event_handler::callbacks, EV_ERROR_MEMORY_EXHAUSTED, EV_ERROR_SUCCESS, hlx_api::free_entry, _hlx_event_callback::group_id, HLX_UNUSED, and slist_new_head().
Referenced by _hlx_event_register_callback_task_with_callback_and_group(), and hlx_event_register_callback_func_with_group().
{
HLX_UNUSED(id);
HLX_UNUSED(manager);
callback->group_id = group_id;
if (slist_new_head(handler->callbacks, callback) == 0)
{
gl_api.free_entry(callback);
return (EV_ERROR_MEMORY_EXHAUSTED);
}
return (EV_ERROR_SUCCESS);
}
| _hlx_event_handler* _hlx_event_return_handler_by_hash | ( | _hlx_event_manager * | manager, |
| unsigned long | id | ||
| ) |
Definition at line 111 of file parallel_events.c.
References _hlx_event_manager::handlers, slist_get_head_and_then_next(), and slist_get_user_data_from_element().
Referenced by _hlx_event_handler_create_by_hash(), and _hlx_event_return_handler().
{
_hlx_event_handler* handler;
struct slist_element* it;
it = 0;
while (slist_get_head_and_then_next(manager->handlers, &it))
if (slist_get_user_data_from_element(it, (void **)&handler) && handler->hash_code == id)
return (handler);
return (0);
}
| hlx_event_manager* hlx_event_manager_create | ( | void | ) |
Create a new event manager
Definition at line 52 of file parallel_events.c.
References _hlx_event_manager::handlers, hlx_api::malloc_entry, and slist_new().
Referenced by hlx_event_get_default_manager().
{
_hlx_event_manager* manager;
if ((manager = gl_api.malloc_entry(sizeof(*manager))) == 0)
return 0;
slist_new(&manager->handlers, 0, 0);
return ((hlx_event_manager*)manager);
}
| void hlx_event_manager_destroy | ( | hlx_event_manager * | manager | ) |
Destroy the event manager
Definition at line 62 of file parallel_events.c.
References _hlx_event_default_manager_destroy(), _hlx_event_handler_destroy(), hlx_api::free_entry, slist_delete(), slist_get_head_and_then_next(), and slist_get_user_data_from_element().
Referenced by hlx_scheduler_destruct().
{
struct slist_element* it;
_hlx_event_handler* handler;
it = 0;
while (slist_get_head_and_then_next(((_hlx_event_manager*)manager)->handlers, &it))
{
slist_get_user_data_from_element(it, (void **)&handler);
_hlx_event_handler_destroy(handler);
gl_api.free_entry(handler);
}
slist_delete(((_hlx_event_manager*)manager)->handlers);
_hlx_event_default_manager_destroy();
}
| hlx_event_errors hlx_event_notify | ( | hlx_event_manager * | manager, |
| unsigned long | id, | ||
| void * | event_data | ||
| ) |
Raise an event
| manager | The event manager where the event is attached |
| id | The event Id (you can use hlx_hash) |
| task | The user task. |
| event_data | User event data (the size of the content must be equal to the size specified in hlx_event_handler_create()). You can pass NULL if you use HLX_EVENT_NO_ARGS Important : This method create internally a copy of the parameter. |
Definition at line 123 of file parallel_events.c.
References _hlx_event_return_handler(), _hlx_event_task_callback(), hlx_event_args::callback, _hlx_event_handler::callbacks, EV_ERROR_MEMORY_EXHAUSTED, EV_ERROR_NO_EVENT_DATA, EV_ERROR_SUCCESS, EV_ERROR_UNDEFINED, hlx_event_args::event_data, hlx_core_add_task_callback(), hlx_core_add_task_in_group_callback(), hlx_api::malloc_entry, hlx_api::memcpy_entry, _hlx_event_handler::param_size, slist_get_head_and_then_next(), slist_get_user_data_from_element(), and hlx_event_args::user_data.
{
_hlx_event_handler* handler;
_hlx_event_callback* callback;
hlx_event_args* task_args;
hlx_event_args func_args;
struct slist_element* it;
if ((handler = _hlx_event_return_handler((_hlx_event_manager*)manager, id)) == 0)
return (EV_ERROR_UNDEFINED);
if (handler->param_size && event_data == 0)
return (EV_ERROR_NO_EVENT_DATA);
func_args.event_data = event_data;
func_args.callback = 0;
it = 0;
while (slist_get_head_and_then_next(handler->callbacks, &it))
{
slist_get_user_data_from_element(it, (void **)&callback);
if (callback->func)
{
func_args.user_data = callback->params.user_data;
callback->func(&func_args);
}
if (callback->task)
{
if ((task_args = gl_api.malloc_entry(sizeof(hlx_event_args))) == 0)
return (EV_ERROR_MEMORY_EXHAUSTED);
task_args->user_data = callback->params.user_data;
task_args->callback = callback->params.callback;
if (handler->param_size)
{
if ((task_args->event_data = gl_api.malloc_entry(handler->param_size)) == 0)
return (EV_ERROR_MEMORY_EXHAUSTED);
gl_api.memcpy_entry(task_args->event_data, event_data, handler->param_size);
}
else
task_args->event_data = 0;
if (callback->group_id > 0)
hlx_core_add_task_in_group_callback(callback->task, task_args, callback->group_id, 0, _hlx_event_task_callback);
else
hlx_core_add_task_callback(callback->task, task_args, 0, _hlx_event_task_callback);
}
}
return (EV_ERROR_SUCCESS);
}
Definition at line 50 of file parallel_sched.c.
1.7.4