EM-ODP 4.4.0
Event Machine on ODP
Loading...
Searching...
No Matches
Event User Area
Collaboration diagram for Event User Area:

Data Structures

struct  em_event_uarea_info_t
 Event user area information filled by em_event_uarea_info() More...
 

Macros

#define em_event_uarea_get   em_event_uarea
 
#define em_event_uarea_id_get   em_event_uarea_id
 

Functions

void * em_event_uarea (em_event_t event, size_t *size)
 Get a pointer to the event user area, optionally along with its size.
 
em_status_t em_event_uarea_id (em_event_t event, bool *isset, uint16_t *id)
 Get the event user area ID along with information if it has been set.
 
em_status_t em_event_uarea_id_set (em_event_t event, uint16_t id)
 Set the event user area ID.
 
em_status_t em_event_uarea_info (em_event_t event, em_event_uarea_info_t *uarea_info)
 Get the event user area information for a given event.
 

Detailed Description

Event User Area

An event may additionally contain a user area separate from the event payload. The size of the event user area is set when creating the event pool from which the event is allocated. The user area is a fixed size (per pool) data area into which event related state data can be stored without having to access and change the payload. Note that the size of the event user area can be zero(0), depending on event pool configuration. Note also that the user area content is not initialized by EM, neither em_alloc() nor em_free() will touch it and thus it might contain old user data set the last time the area was used during a previous allocation of the same event. Since the user area is not part of the event payload, it will not be transmitted as part of a packet etc. A user area ID can further be used to identify the user area contents. The event user area ID is stored outside of the user area itself and is thus always available, even if the size of the user area data is set to zero(0). See em_pool_create(), em_event_uarea(), em_event_uarea_id/set() and em_event_uarea_info() for more information on the event user area and its associated ID.

Macro Definition Documentation

◆ em_event_uarea_get

#define em_event_uarea_get   em_event_uarea

Definition at line 985 of file event_machine_event.h.

◆ em_event_uarea_id_get

#define em_event_uarea_id_get   em_event_uarea_id

Definition at line 1020 of file event_machine_event.h.

Function Documentation

◆ em_event_uarea()

void * em_event_uarea ( em_event_t  event,
size_t *  size 
)

Get a pointer to the event user area, optionally along with its size.

The event user area is a fixed sized area located within the event metadata (i.e. outside of the event payload) that can be used to store application specific event related data without the need to adjust the payload. The event user area is configured during EM event pool creation and thus the size of the user area is set per pool.

Note that the user area content is not initialized by EM, neither em_alloc() nor em_free() will touch it and thus it might contain old user data set the last time the area was used during a previous allocation of the same event. Since the user area is not part of the event payload, it will not be transmitted as part of a packet etc.

Parameters
eventEvent handle to get the user area of
[out]sizeOptional output arg into which the user area size is stored. Use 'size=NULL' if no size information is needed.
Returns
a pointer to the event user area
Return values
NULLon error or if the event contains no user area
See also
em_pool_create() for pool specific configuration and the CLI (Command Line Interface) related runtime config file em-odp.conf for the default value: 'pool.user_area_size'.
em_event_uarea_info() if both user area ptr and ID is needed
Examples
bench_event.c, and queue_types_ag.c.

Definition at line 1642 of file event_machine_event.c.

◆ em_event_uarea_id()

em_status_t em_event_uarea_id ( em_event_t  event,
bool *  isset,
uint16_t *  id 
)

Get the event user area ID along with information if it has been set.

The event user area can be associated with an optional ID that e.g. can be used to identify the contents of the actual user area data. The ID is stored outside of the actual user area data and is available for use even if the user area size has been set to zero(0) for the pool the event was allocated from.

This function is used to determine whether the user area ID has been set earlier and to retrieve the ID in the case it has been set. EM will initialize 'ID isset = false' when allocating a new event (indicating that the ID is not set). Use em_event_uarea_id_set() to set the ID.

Parameters
eventEvent handle to get the user area ID and "set"-status of
[out]issetOptional output arg: has the ID been set previously? At least one of 'isset' and 'id' must be given (or both).
[out]idOptional output arg into which the user area ID is stored if it has been set before. The output arg 'isset' should be used to determine whether 'id' has been set. Note: 'id' will not be touched if the ID has not been set earlier (i.e. when 'isset' is 'false'). At least one of 'isset' and 'id' must be given (or both).
Returns
EM_OK if successful
See also
em_event_uarea_id_set(), em_event_uarea()
em_event_uarea_info() if both user area ptr and ID is needed
Examples
bench_event.c.

Definition at line 1701 of file event_machine_event.c.

◆ em_event_uarea_id_set()

em_status_t em_event_uarea_id_set ( em_event_t  event,
uint16_t  id 
)

Set the event user area ID.

The event user area can be associated with an optional ID that e.g. can be used to identify the contents of the actual user area data. The ID is stored outside of the actual user area data and is available for use even if the user area size has been set to 0 for the pool the event was allocated from.

This function is used to set the event user area ID for the given event. The 'set' operation overwrites any ID stored earlier. Use em_event_uarea_id() to check whether an ID has been set earlier and to retrieve the ID.

Parameters
eventEvent handle for which to set the user area ID
idThe user area ID to set
Returns
EM_OK if successful
See also
em_event_uarea_id(), em_event_uarea(), em_event_uarea_info()
Examples
bench_event.c, and queue_types_ag.c.

Definition at line 1679 of file event_machine_event.c.

◆ em_event_uarea_info()

em_status_t em_event_uarea_info ( em_event_t  event,
em_event_uarea_info_t uarea_info 
)

Get the event user area information for a given event.

Obtain information about the event user area for a certain given event. Information containing the user area pointer, size, as well as the ID is output via the 'uarea_info' struct. This API function combines the functionality of em_event_uarea() and em_event_uarea_id() for use cases where both the user area pointer as well as the ID is needed. Calling one API function instead of two might be faster due to a fewer checks and internal conversions.

The event user area is a fixed sized area located within the event metadata (i.e. outside of the event payload) that can be used to store application specific event related data without the need to adjust the payload. The event user area is configured during EM event pool creation and thus the size of the user area is set per pool.

Note that the user area content is not initialized by EM, neither em_alloc() nor em_free() will touch it and thus it might contain old user data set the last time the area was used during a previous allocation of the same event. Since the user area is not part of the event payload, it will not be transmitted as part of a packet etc.

The event user area can be associated with an optional ID that can be used to identify the contents of the actual user area data. The ID is stored outside of the actual user area data and is available for use even if the user area size has been set to zero(0) for the pool the event was allocated from. EM will initialize 'uarea_info.id.isset = false' when allocating a new event (indicating that the ID is not set).

Parameters
eventEvent handle to get the user area information of.
[out]uarea_infoOutput struct into which the user area information is stored.
Returns
EM status code indicating success or failure of the operation.
Return values
EM_OKOperation successful.
OtherOperation FAILED and no valid user area info could be obtained, 'uarea_info' is all NULL/zero(0) in this case.
See also
em_pool_create() for pool specific configuration and the CLI (Command Line Interface) related runtime config file em-odp.conf for the default value: 'pool.user_area_size'.
em_event_uarea(), em_event_uarea_id()
Examples
bench_event.c, and queue_types_ag.c.

Definition at line 1738 of file event_machine_event.c.