XROAD
xroad_reactor.h File Reference
Include dependency graph for xroad_reactor.h:

Go to the source code of this file.

Classes

struct  xroad_reactor_params_t
 Structure of parameters. More...
 

Macros

#define xroad_reactor_create(_name, ...)
 

Typedefs

typedef struct xroad_reactor_s xroad_reactor_t
 Opaque reactor structure.
 

Enumerations

enum  xroad_reactor_flags_t { xroad_rf_none = 0u , xroad_rf_fixed_fd = (1u << 0u) , xroad_rf_write_append = (2u << 0u) }
 

Functions

xroad_reactor_t * xroad_reactor_create_ex (xroad_str_t name, xroad_reactor_params_t params)
 
xroad_errno_t xroad_reactor_set_interval (xroad_reactor_t *r, int wait_time_ms)
 Change wait time.
 
void xroad_reactor_set_default (xroad_reactor_t *r)
 
const xroad_reactor_timestamps_t * xroad_reactor_get_timestamps (xroad_reactor_t *r) __attribute_const__
 Returns pointer to timestamps structure associated with the reactor.
 
xroad_reactor_t * xroad_reactor_get_default (void)
 
void xroad_reactor_destroy (xroad_reactor_t *r)
 
int32_t xroad_reactor_process (xroad_reactor_t *r)
 
int32_t xroad_reactor_process_nowait (xroad_reactor_t *r)
 
xroad_errno_t xroad_reactor_add_epoll (xroad_reactor_t *r, uint32_t events, xroad_epoll_callback_t *cback, uint8_t flags)
 
xroad_errno_t xroad_reactor_mod_epoll (xroad_reactor_t *r, uint32_t events, xroad_epoll_callback_t *cback, uint8_t flags)
 
int32_t xroad_reactor_get_epoll_fd (xroad_reactor_t *r)
 
int xroad_reactor_reg_fd (xroad_reactor_t *r, int fd)
 
int xroad_reactor_unreg_fd (xroad_reactor_t *r, int reg_fd)
 Unregister the file descriptor.
 
int xroad_reactor_reg_fd_to_fd (xroad_reactor_t *r, int reg_fd)
 Get real (native) file descriptor by registered one (registration index)
 

Detailed Description

Author
Vladimir Solontsov

Macro Definition Documentation

◆ xroad_reactor_create

#define xroad_reactor_create (   _name,
  ... 
)
Value:
({ \
xroad_reactor_params_t args = {.params_size = sizeof(xroad_reactor_params_t), ##__VA_ARGS__}; \
xroad_reactor_create_ex(_name, args); \
})
Structure of parameters.
Definition: xroad_reactor.h:23

Function Documentation

◆ xroad_reactor_add_epoll()

xroad_errno_t xroad_reactor_add_epoll ( xroad_reactor_t *  r,
uint32_t  events,
xroad_epoll_callback_t *  cback,
uint8_t  flags 
)

add descriptor to epoll

Parameters
[in]r- reactor instance or null to use the default one
[in]events- fd events
[in]cback- pointer to epoll callback
[in]flags- additional flags from xroad_reactor_flags_t
Returns
XROAD_ERROR_OK - done

◆ xroad_reactor_create_ex()

xroad_reactor_t* xroad_reactor_create_ex ( xroad_str_t  name,
xroad_reactor_params_t  params 
)

Create a new reactor instance

Parameters
name– some name for the reactor. It's only used for its logger.
params– parameters
Returns
– created reactor or NULL in case of error

◆ xroad_reactor_destroy()

void xroad_reactor_destroy ( xroad_reactor_t *  r)

Destroy the reactor

Parameters
r- reactor to destroy

◆ xroad_reactor_get_default()

xroad_reactor_t* xroad_reactor_get_default ( void  )

Get the default thread-local reactor

Returns
- default reactor for current thread or NULL if it's not set.

◆ xroad_reactor_get_epoll_fd()

int32_t xroad_reactor_get_epoll_fd ( xroad_reactor_t *  r)

return epoll file descriptor

Parameters
[in]r- reactor instance or null to use the default one
Returns
- epoll_fd

◆ xroad_reactor_mod_epoll()

xroad_errno_t xroad_reactor_mod_epoll ( xroad_reactor_t *  r,
uint32_t  events,
xroad_epoll_callback_t *  cback,
uint8_t  flags 
)

modify or delete (events = 0) the descriptor from polling

Parameters
[in]r- reactor instance or null to use the default one
[in]events- new fd events (0u to delete)
[in]cback- pointer to epoll callback
[in]flags- RESERVED. additional flags from xroad_reactor_flags_t
Returns
XROAD_ERROR_OK - done

◆ xroad_reactor_process()

int32_t xroad_reactor_process ( xroad_reactor_t *  r)

Receive and dispatch events and callbacks. Use configured timeout.

Parameters
r- reactor instance or null to use the default one
Returns
- >= 0 number of dispatched events, < 0 - error happened (see xroad_errno_t)

◆ xroad_reactor_process_nowait()

int32_t xroad_reactor_process_nowait ( xroad_reactor_t *  r)

Receive and dispatch events and callbacks without waiting.

Parameters
r- reactor instance or null to use the default one
Returns
- >= 0 number of dispatched events, < 0 - error happened (see xroad_errno_t)

◆ xroad_reactor_reg_fd()

int xroad_reactor_reg_fd ( xroad_reactor_t *  r,
int  fd 
)

Register a file descriptor.

NB Please specify xroad_rf_fixed_fd flag to indicate the fd is registered index instead of native fd.

Parameters
r- reactor
fd- real (native) file descriptor
Returns
- registered fd (non-negative) or error (xroad_errno_t).

◆ xroad_reactor_set_default()

void xroad_reactor_set_default ( xroad_reactor_t *  r)

Set a default reactor for current thread

Parameters
[in]-reactor to set as the default one