NUGU SDK Linux  1.7.6
Event Queue

Event queue for passing events between threads. More...

+ Collaboration diagram for Event Queue:

Typedefs

typedef void(* NuguEqueueCallback) (enum nugu_equeue_type type, void *data, void *userdata)
 Callback prototype for receiving an event.
 
typedef void(* NuguEqueueDestroyCallback) (void *data)
 Callback prototype for releasing data after event delivery is done.
 

Enumerations

enum  nugu_equeue_type {
  NUGU_EQUEUE_TYPE_NEW_DIRECTIVE = 0 , NUGU_EQUEUE_TYPE_NEW_ATTACHMENT , NUGU_EQUEUE_TYPE_INVALID_TOKEN , NUGU_EQUEUE_TYPE_SEND_PING_FAILED ,
  NUGU_EQUEUE_TYPE_EVENT_SEND_RESULT , NUGU_EQUEUE_TYPE_EVENT_RESPONSE , NUGU_EQUEUE_TYPE_REGISTRY_HEALTH , NUGU_EQUEUE_TYPE_REGISTRY_SERVERS ,
  NUGU_EQUEUE_TYPE_REGISTRY_FAILED , NUGU_EQUEUE_TYPE_SERVER_CONNECTED , NUGU_EQUEUE_TYPE_SERVER_DISCONNECTED , NUGU_EQUEUE_TYPE_DIRECTIVES_CLOSED ,
  NUGU_EQUEUE_TYPE_MAX = 255
}
 event types More...
 

Functions

NUGU_API void nugu_equeue_deinitialize (void)
 De-initialize the event queue.
 
NUGU_API int nugu_equeue_initialize (void)
 Initialize the event queue. More...
 
NUGU_API int nugu_equeue_push (enum nugu_equeue_type type, void *data)
 Push new event with data to queue and trigger event callback in GMainloop thread context. More...
 
NUGU_API int nugu_equeue_set_handler (enum nugu_equeue_type type, NuguEqueueCallback callback, NuguEqueueDestroyCallback destroy_callback, void *userdata)
 Set handler for event type. More...
 
NUGU_API int nugu_equeue_unset_handler (enum nugu_equeue_type type)
 Unset handler for event type. More...
 

Detailed Description

Event queue for passing events between threads.

Queue for raising event callbacks with passing data from another thread to the thread context in which GMainloop runs.

Manage the queue thread-safely using GAsyncQueue and wakeup the GMainloop using eventfd.

Enumeration Type Documentation

◆ nugu_equeue_type

event types

Enumerator
NUGU_EQUEUE_TYPE_NEW_DIRECTIVE 

received new directive

NUGU_EQUEUE_TYPE_NEW_ATTACHMENT 

received new attachment

NUGU_EQUEUE_TYPE_INVALID_TOKEN 

received invalid token response

NUGU_EQUEUE_TYPE_SEND_PING_FAILED 

failed to send ping request

NUGU_EQUEUE_TYPE_EVENT_SEND_RESULT 

result of event sent

NUGU_EQUEUE_TYPE_EVENT_RESPONSE 

directive response of event request

NUGU_EQUEUE_TYPE_REGISTRY_HEALTH 

received health check policy

NUGU_EQUEUE_TYPE_REGISTRY_SERVERS 

received server list

NUGU_EQUEUE_TYPE_REGISTRY_FAILED 

failed to connect device-gateway-registry

NUGU_EQUEUE_TYPE_SERVER_CONNECTED 

connected to server

NUGU_EQUEUE_TYPE_SERVER_DISCONNECTED 

disconnected from server

NUGU_EQUEUE_TYPE_DIRECTIVES_CLOSED 

directives stream closed by server

NUGU_EQUEUE_TYPE_MAX 

maximum value for type id

Function Documentation

◆ nugu_equeue_initialize()

NUGU_API int nugu_equeue_initialize ( void  )

Initialize the event queue.

Returns
result
Return values
0success
-1failure

◆ nugu_equeue_set_handler()

NUGU_API int nugu_equeue_set_handler ( enum nugu_equeue_type  type,
NuguEqueueCallback  callback,
NuguEqueueDestroyCallback  destroy_callback,
void *  userdata 
)

Set handler for event type.

Parameters
[in]typetype-id
[in]callbackcallback function
[in]destroy_callbackdestroy notifier function
[in]userdatadata to pass to the user callback
Returns
result
Return values
0success
-1failure

◆ nugu_equeue_unset_handler()

NUGU_API int nugu_equeue_unset_handler ( enum nugu_equeue_type  type)

Unset handler for event type.

Parameters
[in]typetype-id
Returns
result
Return values
0success
-1failure

◆ nugu_equeue_push()

NUGU_API int nugu_equeue_push ( enum nugu_equeue_type  type,
void *  data 
)

Push new event with data to queue and trigger event callback in GMainloop thread context.

Parameters
[in]typetype-id
[in]dataevent data
Returns
result
Return values
0success
-1failure