#include <stdint.h>
#include "sopc_enums.h"
Go to the source code of this file.
◆ SOPC_EventHandler
Processes messages from a queue.
An SOPC_EventHandler processes the messages from its queue with a callback function. That callback function is called in the thread of the looper to which the event handler is attached. Posting event is safe to do from other threads.
◆ SOPC_Looper
Manages the processing of events on a given thread.
A SOPC_Looper owns a thread on which the callbacks from one or more event handlers will be processed.
◆ SOPC_SetListenerFunc
Function prototype for connecting an event emitter to a listener.
◆ SOPC_EventHandler_Callback
typedef void SOPC_EventHandler_Callback(SOPC_EventHandler *handler, int32_t event, uint32_t eltId, uintptr_t params, uintptr_t auxParam) |
Function prototype for message processing callbacks.
handler
is a pointer to the SOPC_EventHandler
invoking this callback, the other parameters (and their lifetime) are specific to the event invoked.
◆ SOPC_EventHandler_Create()
Creates a new event handler and attaches it to an existing looper.
- Parameters
-
looper | the looper to attach the event handler to |
callback | the callback to call to process incoming messages |
The returned handler belongs to the looper, and will be freed with it.
- Returns
- The created event handler, or
NULL
on memory allocation failure.
◆ SOPC_EventHandler_Post()
Posts an event to the back of the event handler's message queue.
- Parameters
-
handler | the event handler |
event | the event code |
eltId | event specific data |
params | event specific data |
auxParam | event specific data |
- Returns
SOPC_STATUS_OK
on success, or an error code on failure.
◆ SOPC_EventHandler_PostAsNext()
Posts an event to the front of the event handler's message queue.
- Parameters
-
handler | the event handler |
event | the event code |
eltId | event specific data |
params | event specific data |
auxParam | event specific data |
- Returns
SOPC_STATUS_OK
on success, or an error code on failure.
◆ SOPC_Looper_Create()
SOPC_Looper* SOPC_Looper_Create |
( |
const char * |
threadName | ) |
|
Creates a new looper and attaches it to a new thread.
- Parameters
-
threadName | name of the thread |
- Returns
- The created looper, or
NULL
in case or error.
◆ SOPC_Looper_Delete()
Stops a looper and releases all resources allocated to it.
- Parameters
-
The queues of the attached handlers will be processed before the thread of the looper is stopped.