Helixis 1.0
Task Programming API
Functions | Variables
sources/events.c File Reference
#include "hlx/core.h"
#include "helixis_internal.h"

Go to the source code of this file.

Functions

void _hlx_event_delete_callback (void *data, void *state)
void _hlx_event_default_manager_destroy (void)
hlx_event_managerhlx_event_get_default_manager ()
hlx_event_errors hlx_event_handler_create (hlx_event_manager *public_manager, unsigned long id, unsigned int size)
hlx_event_errors hlx_event_handler_destroy (hlx_event_manager *public_manager, unsigned long id)
hlx_event_errors hlx_event_register_callback_func_with_group (hlx_event_manager *public_manager, unsigned long id, hlx_event_user_callback user_callback, void *user_data, hlx_group_id group_id)
hlx_event_errors hlx_event_register_callback_func (hlx_event_manager *public_manager, unsigned long id, hlx_event_user_callback user_callback, void *user_data)
hlx_event_errors _hlx_event_register_callback_task_with_callback_and_group (hlx_event_manager *public_manager, unsigned long id, hlx_task_func user_callback, void *user_data, hlx_task_callback task_callback, hlx_group_id group_id)
hlx_event_errors _hlx_event_register_callback_task_with_callback (hlx_event_manager *public_manager, unsigned long id, hlx_task_func task, void *user_data, hlx_task_callback task_callback)
hlx_event_errors hlx_event_register_callback_task_with_group (hlx_event_manager *public_manager, unsigned long id, hlx_task_func user_callback, void *user_data, hlx_group_id group_id)
hlx_event_errors hlx_event_register_callback_task (hlx_event_manager *public_manager, unsigned long id, hlx_task_func user_callback, void *user_data)
_hlx_event_handler_hlx_event_return_handler (_hlx_event_manager *manager, unsigned long id)
void _hlx_event_task_callback (void *param, hlx_group_id group_id, int status)

Variables

hlx_api gl_api
static hlx_event_managergl_event_manager = 0

Function Documentation

void _hlx_event_default_manager_destroy ( void  )

Definition at line 63 of file events.c.

References hlx_api::free_entry.

Referenced by hlx_event_manager_destroy().

void _hlx_event_delete_callback ( void *  data,
void *  state 
)

Definition at line 54 of file events.c.

References hlx_api::free_entry.

Referenced by _hlx_event_handler_create_by_hash().

{
        _hlx_event_callback*    callback;

        (void)state;
        callback = (_hlx_event_callback*)data;
        gl_api.free_entry(callback);
}
hlx_event_errors _hlx_event_register_callback_task_with_callback ( hlx_event_manager public_manager,
unsigned long  id,
hlx_task_func  task,
void *  user_data,
hlx_task_callback  task_callback 
)

Definition at line 133 of file events.c.

References _hlx_event_register_callback_task_with_callback_and_group().

{
        return _hlx_event_register_callback_task_with_callback_and_group(public_manager, id, task, user_data, task_callback, 0);
}
hlx_event_errors _hlx_event_register_callback_task_with_callback_and_group ( hlx_event_manager public_manager,
unsigned long  id,
hlx_task_func  user_callback,
void *  user_data,
hlx_task_callback  task_callback,
hlx_group_id  group_id 
)
_hlx_event_handler* _hlx_event_return_handler ( _hlx_event_manager manager,
unsigned long  id 
)
void _hlx_event_task_callback ( void *  param,
hlx_group_id  group_id,
int  status 
)

Definition at line 153 of file events.c.

References hlx_event_args::callback, hlx_event_args::event_data, and hlx_api::free_entry.

Referenced by hlx_event_notify().

{
        hlx_event_args* args;

        args = (hlx_event_args*)param;
        if (args->callback)
                args->callback(param, group_id, status);
        if (args->event_data)
                gl_api.free_entry(args->event_data);
        gl_api.free_entry(args);
}
hlx_event_manager* hlx_event_get_default_manager ( void  )

Get the default event manager (Never call hlx_event_manager_destroy() for this manager)

See also:
hlx_event_manager_create()
Returns:
The default event manager pointer

Definition at line 70 of file events.c.

References hlx_event_manager_create().

Referenced by hlx_scheduler_destruct().

hlx_event_errors hlx_event_handler_create ( hlx_event_manager manager,
unsigned long  id,
unsigned int  size 
)

Create a new event in the given manager

Parameters:
managerThe event manager where the event will be attached
idThe event Id (you can use hlx_hash)
sizeThe size of the user data (for hlx_event_notify). HLX_EVENT_NO_ARGS for no user arg.
See also:
hlx_hash()
hlx_event_manager_create()
Returns:
Event creation status

Definition at line 77 of file events.c.

References _hlx_event_handler_create_by_hash().

{
        return (_hlx_event_handler_create_by_hash((_hlx_event_manager*)public_manager, id, size));
}
hlx_event_errors hlx_event_handler_destroy ( hlx_event_manager manager,
unsigned long  id 
)

Destroy The given event

Parameters:
managerThe event manager where the event is attached
idThe event Id (you can use hlx_hash)
See also:
hlx_hash()
hlx_event_manager_create()
Returns:
Event deletion status

Definition at line 82 of file events.c.

References _hlx_event_handler_destroy(), _hlx_event_return_handler(), EV_ERROR_SUCCESS, and EV_ERROR_UNDEFINED.

{
        _hlx_event_handler*     handler;

        if ((handler = _hlx_event_return_handler((_hlx_event_manager*)public_manager, id)) == 0)
                return (EV_ERROR_UNDEFINED);
        _hlx_event_handler_destroy(handler);
        return (EV_ERROR_SUCCESS);
}
hlx_event_errors hlx_event_register_callback_func ( hlx_event_manager manager,
unsigned long  id,
hlx_event_user_callback  func,
void *  user_data 
)

Attach a callback to the given event

Parameters:
managerThe event manager where the event is attached
idThe event Id (you can use hlx_hash)
funcThe user callback.
user_dataUser data in addition to the event data.
See also:
hlx_hash()
hlx_event_manager_create()
Returns:
Event registration status

Definition at line 110 of file events.c.

References hlx_event_register_callback_func_with_group().

{
        return hlx_event_register_callback_func_with_group(public_manager, id, user_callback, user_data, 0);
}
hlx_event_errors hlx_event_register_callback_func_with_group ( hlx_event_manager manager,
unsigned long  id,
hlx_event_user_callback  func,
void *  user_data,
hlx_group_id  group_id 
)

Attach a callback to the given event. the callback will be called from the given group

Parameters:
managerThe event manager where the event is attached
idThe event Id (you can use hlx_hash)
funcThe user callback.
user_dataUser data in addition to the event data.
group_idThe group where the callback will be called
See also:
hlx_hash()
hlx_event_manager_create()
Returns:
Event registration status

Definition at line 92 of file events.c.

References _hlx_event_register_callback_with_group(), _hlx_event_return_handler(), _hlx_event_params::callback, EV_ERROR_MEMORY_EXHAUSTED, EV_ERROR_UNDEFINED, _hlx_event_callback::func, hlx_api::malloc_entry, _hlx_event_callback::params, _hlx_event_callback::task, and _hlx_event_params::user_data.

Referenced by hlx_event_register_callback_func().

{
        _hlx_event_manager*             manager;
        _hlx_event_handler*             handler;
        _hlx_event_callback*    callback;

        manager = (_hlx_event_manager*)public_manager;
        if ((handler = _hlx_event_return_handler(manager, id)) == 0)
                return (EV_ERROR_UNDEFINED);
        if ((callback = gl_api.malloc_entry(sizeof(*callback))) == 0)
                return (EV_ERROR_MEMORY_EXHAUSTED);
        callback->func = user_callback;
        callback->params.callback = 0;
        callback->params.user_data = user_data;
        callback->task = 0;
        return (_hlx_event_register_callback_with_group(manager, handler, id, callback, group_id));
}
hlx_event_errors hlx_event_register_callback_task ( hlx_event_manager manager,
unsigned long  id,
hlx_task_func  task,
void *  user_data 
)

Attach a task to the given event

Parameters:
managerThe event manager where the event is attached
idThe event Id (you can use hlx_hash)
taskThe user task.
user_dataUser data in addition to the event data.
See also:
hlx_hash()
hlx_event_manager_create()
Returns:
Event registration status

Definition at line 143 of file events.c.

References _hlx_event_register_callback_task_with_callback_and_group().

{
        return _hlx_event_register_callback_task_with_callback_and_group(public_manager, id, user_callback, user_data, 0, 0);
}
hlx_event_errors hlx_event_register_callback_task_with_group ( hlx_event_manager manager,
unsigned long  id,
hlx_task_func  task,
void *  user_data,
hlx_group_id  group_id 
)

Attach a task to the given event. the task will be pushed in the given group

Parameters:
managerThe event manager where the event is attached
idThe event Id (you can use hlx_hash)
taskThe user task.
user_dataUser data in addition to the event data.
group_idThe group where the task will be pushed
See also:
hlx_hash()
hlx_event_manager_create()
Returns:
Event registration status

Definition at line 138 of file events.c.

References _hlx_event_register_callback_task_with_callback_and_group().

{
        return _hlx_event_register_callback_task_with_callback_and_group(public_manager, id, user_callback, user_data, 0, group_id);
}

Variable Documentation

Definition at line 42 of file api.c.

Definition at line 48 of file events.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines