![]() |
Generic asynchronous events abstraction. Designed to support multiple event libraries. Only one library is supported per build.
Data Structures | |
struct | as_event_loop |
struct | as_policy_event |
Functions | |
AS_EXTERN as_status | as_create_event_loops (as_error *err, as_policy_event *policy, uint32_t capacity, as_event_loop **event_loops) |
AS_EXTERN bool | as_event_close_loops (void) |
AS_EXTERN as_event_loop * | as_event_create_loops (uint32_t capacity) |
AS_EXTERN void | as_event_destroy_loops (void) |
AS_EXTERN as_event_loop * | as_event_loop_find (void *loop) |
static as_event_loop * | as_event_loop_get (void) |
static as_event_loop * | as_event_loop_get_by_index (uint32_t index) |
static int | as_event_loop_get_process_size (as_event_loop *event_loop) |
static uint32_t | as_event_loop_get_queue_size (as_event_loop *event_loop) |
AS_EXTERN as_event_loop * | as_event_set_external_loop (void *loop) |
AS_EXTERN bool | as_event_set_external_loop_capacity (uint32_t capacity) |
static void | as_policy_event_init (as_policy_event *policy) |
AS_EXTERN as_status | as_set_external_event_loop (as_error *err, as_policy_event *policy, void *loop, as_event_loop **event_loop) |
AS_EXTERN as_status as_create_event_loops | ( | as_error * | err, |
as_policy_event * | policy, | ||
uint32_t | capacity, | ||
as_event_loop ** | event_loops ) |
Create new aerospike internal event loops with specified event policy. These event loops are used exclusively for aerospike database commands and are not shared with the application for other tasks. If shared event loops are desired, use as_event_set_external_loop_capacity() and as_set_external_event_loop() instead.
This function must be called before aerospike_connect().
err | The as_error to be populated if an error occurs. |
policy | Event loop configuration. Pass in NULL for default configuration. |
capacity | Number of event loops to create. |
event_loops | Created event loops. Pass in NULL if event loops do not need to be retrieved. |
AS_EXTERN bool as_event_close_loops | ( | void | ) |
Close internal event loops and release watchers for internal and external event loops. The global event loop array will also be destroyed for internal event loops.
This method should be called once on program shutdown if as_event_create_loops() or as_event_set_external_loop_capacity() was called.
The shutdown sequence is slightly different for internal and external event loops.
Internal:
External:
AS_EXTERN as_event_loop * as_event_create_loops | ( | uint32_t | capacity | ) |
Create new aerospike internal event loops with default event policy. These event loops are used exclusively for aerospike database commands and are not shared with the application for other tasks. If shared event loops are desired, use as_event_set_external_loop_capacity() and as_event_set_external_loop() instead.
This function must be called before aerospike_connect().
capacity | Number of event loops to create. |
AS_EXTERN void as_event_destroy_loops | ( | void | ) |
Destroy global event loop array. This function only needs to be called for external event loops.
AS_EXTERN as_event_loop * as_event_loop_find | ( | void * | loop | ) |
Find client's event loop abstraction given the external event loop.
loop | External event loop. |
|
inlinestatic |
Retrieve a random event loop using round robin distribution.
Definition at line 385 of file as_event.h.
References as_event_loop_current, and as_event_loop::next.
|
inlinestatic |
Retrieve event loop by array index.
index | Event loop array index. |
Definition at line 372 of file as_event.h.
References as_event_loop_size, as_event_loops, and as_event_loop::index.
|
inlinestatic |
Return the approximate number of commands currently being processed on the event loop. The value is approximate because the call may be from a different thread than the event loop’s thread and there are no locks or atomics used.
Definition at line 403 of file as_event.h.
References as_event_loop::pending.
|
inlinestatic |
Return the approximate number of commands stored on this event loop's delay queue that have not been started yet. The value is approximate because the call may be from a different thread than the event loop’s thread and there are no locks or atomics used.
Definition at line 417 of file as_event.h.
References as_queue_size(), and as_event_loop::delay_queue.
AS_EXTERN as_event_loop * as_event_set_external_loop | ( | void * | loop | ) |
Register an aerospike external event loop with the client with default event policy.
This method should be called when the calling program wants to share event loops with the client. This reduces resource usage and can increase performance.
This method must be called in the same thread as the event loop that is being registered.
This method is used in conjunction with as_event_set_external_loop_capacity() to fully define the external loop to the client and obtain a reference to the client's event loop abstraction.
loop | External event loop. |
AS_EXTERN bool as_event_set_external_loop_capacity | ( | uint32_t | capacity | ) |
Set the number of aerospike external event loops. This method should be called when the application wants to share event loops with the client. This reduces resource usage and can increase performance.
This method is used in conjunction with as_event_set_external_loop() or as_set_external_event_loop() to fully define the the external loop to the client and obtain a reference to the client's event loop abstraction.
capacity | Number of externally created event loops. |
|
inlinestatic |
Initialize event loop configuration variables.
Definition at line 159 of file as_event.h.
References as_policy_event::max_commands_in_process, as_policy_event::max_commands_in_queue, and as_policy_event::queue_initial_capacity.
AS_EXTERN as_status as_set_external_event_loop | ( | as_error * | err, |
as_policy_event * | policy, | ||
void * | loop, | ||
as_event_loop ** | event_loop ) |
Register an aerospike external event loop with the client with specified event policy.
This method should be called when the calling program wants to share event loops with the client. This reduces resource usage and can increase performance.
This method must be called in the same thread as the event loop that is being registered.
This method is used in conjunction with as_event_set_external_loop_capacity() to fully define the external loop to the client and obtain a reference to the client's event loop abstraction.
err | The as_error to be populated if an error occurs. |
policy | Event loop configuration. Pass in NULL for default configuration. |
loop | External event loop. |
event_loop | Created event loop. |