internal API to access the 'operations' subsystem More...
Go to the source code of this file.
Typedefs | |
typedef void(* | OperationStart) (void *cls) |
Function to call to start an operation once all queues the operation is part of declare that the operation can be activated. More... | |
typedef void(* | OperationRelease) (void *cls) |
Function to call to cancel an operation (release all associated resources). More... | |
Enumerations | |
enum | OperationQueueType { OPERATION_QUEUE_TYPE_FIXED , OPERATION_QUEUE_TYPE_ADAPTIVE } |
The type of operation queue. More... | |
Functions | |
struct OperationQueue * | GNUNET_TESTBED_operation_queue_create_ (enum OperationQueueType type, unsigned int max_active) |
Create an operation queue. More... | |
void | GNUNET_TESTBED_operation_queue_destroy_ (struct OperationQueue *queue) |
Destroy an operation queue. More... | |
int | GNUNET_TESTBED_operation_queue_destroy_empty_ (struct OperationQueue *queue) |
Destroys the operation queue if it is empty. More... | |
void | GNUNET_TESTBED_operation_queue_reset_max_active_ (struct OperationQueue *queue, unsigned int max_active) |
Function to reset the maximum number of operations in the given queue. More... | |
void | GNUNET_TESTBED_operation_queue_insert2_ (struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op, unsigned int nres) |
Add an operation to a queue. More... | |
void | GNUNET_TESTBED_operation_queue_insert_ (struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op) |
Add an operation to a queue. More... | |
void | GNUNET_TESTBED_operation_begin_wait_ (struct GNUNET_TESTBED_Operation *op) |
Marks the given operation as waiting on the queues. More... | |
struct GNUNET_TESTBED_Operation * | GNUNET_TESTBED_operation_create_ (void *cls, OperationStart start, OperationRelease release) |
Create an 'operation' to be performed. More... | |
void | GNUNET_TESTBED_operation_release_ (struct GNUNET_TESTBED_Operation *op) |
An operation is 'done' (was cancelled or finished); remove it from the queues and release associated resources. More... | |
void | GNUNET_TESTBED_operation_inactivate_ (struct GNUNET_TESTBED_Operation *op) |
Marks an active operation as inactive - the operation will be kept in a ready-to-be-released state and continues to hold resources until another operation contents for them. More... | |
void | GNUNET_TESTBED_operation_activate_ (struct GNUNET_TESTBED_Operation *op) |
Marks and inactive operation as active. More... | |
void | GNUNET_TESTBED_operation_mark_failed (struct GNUNET_TESTBED_Operation *op) |
Marks an operation as failed. More... | |
internal API to access the 'operations' subsystem
Definition in file testbed_api_operations.h.
typedef void(* OperationStart) (void *cls) |
Function to call to start an operation once all queues the operation is part of declare that the operation can be activated.
cls | the closure from GNUNET_TESTBED_operation_create_() |
Definition at line 157 of file testbed_api_operations.h.
typedef void(* OperationRelease) (void *cls) |
Function to call to cancel an operation (release all associated resources).
This can be because of a call to "GNUNET_TESTBED_operation_cancel" (before the operation generated an event) or AFTER the operation generated an event due to a call to "GNUNET_TESTBED_operation_done". Thus it is not guaranteed that a callback to the 'OperationStart' precedes the call to 'OperationRelease'. Implementations of this function are expected to clean up whatever state is in 'cls' and release all resources associated with the operation.
cls | the closure from GNUNET_TESTBED_operation_create_() |
Definition at line 173 of file testbed_api_operations.h.
enum OperationQueueType |
The type of operation queue.
Enumerator | |
---|---|
OPERATION_QUEUE_TYPE_FIXED | Operation queue which permits a fixed maximum number of operations to be active at any time. |
OPERATION_QUEUE_TYPE_ADAPTIVE | Operation queue which adapts the number of operations to be active based on the operation completion times of previously executed operation in it. |
Definition at line 43 of file testbed_api_operations.h.
struct OperationQueue* GNUNET_TESTBED_operation_queue_create_ | ( | enum OperationQueueType | type, |
unsigned int | max_active | ||
) |
Create an operation queue.
type | the type of operation queue |
max_active | maximum number of operations in this queue that can be active in parallel at the same time. |
Definition at line 1043 of file testbed_api_operations.c.
References ADAPTIVE_QUEUE_DEFAULT_HISTORY, ADAPTIVE_QUEUE_DEFAULT_MAX_ACTIVE, adaptive_queue_set_max_active(), GNUNET_new, GNUNET_TESTBED_SD_init_(), FeedbackCtx::max_active_bound, OPERATION_QUEUE_TYPE_FIXED, queue(), FeedbackCtx::sd, and type.
Referenced by GNUNET_TESTBED_controller_connect(), GNUNET_TESTBED_get_statistics(), GNUNET_TESTBED_host_create_with_id(), and testbed_run().
void GNUNET_TESTBED_operation_queue_destroy_ | ( | struct OperationQueue * | queue | ) |
Destroy an operation queue.
The queue MUST be empty at this time.
queue | queue to destroy |
Destroy an operation queue.
If the queue is still in use by operations it is marked as expired and its resources are released in the destructor GNUNET_TESTBED_operations_fini().
queue | queue to destroy |
Definition at line 1096 of file testbed_api_operations.c.
References expired_opqs, GNUNET_array_append, GNUNET_assert, GNUNET_YES, is_queue_empty(), n_expired_opqs, queue(), and queue_destroy().
Referenced by GNUNET_TESTBED_controller_disconnect(), GNUNET_TESTBED_host_destroy(), GNUNET_TESTBED_operation_queue_destroy_empty_(), and shutdown_task().
int GNUNET_TESTBED_operation_queue_destroy_empty_ | ( | struct OperationQueue * | queue | ) |
Destroys the operation queue if it is empty.
If not empty return GNUNET_NO.
queue | the queue to destroy if empty |
Definition at line 1117 of file testbed_api_operations.c.
References GNUNET_NO, GNUNET_TESTBED_operation_queue_destroy_(), GNUNET_YES, is_queue_empty(), and queue().
Referenced by oprelease_get_stats().
void GNUNET_TESTBED_operation_queue_reset_max_active_ | ( | struct OperationQueue * | queue, |
unsigned int | max_active | ||
) |
Function to reset the maximum number of operations in the given queue.
If max_active is lesser than the number of currently active operations, the active operations are not stopped immediately.
queue | the operation queue which has to be modified |
max_active | the new maximum number of active operations |
Definition at line 1158 of file testbed_api_operations.c.
References defer(), QueueEntry::op, queue(), and recheck_waiting().
Referenced by adaptive_queue_set_max_active().
void GNUNET_TESTBED_operation_queue_insert2_ | ( | struct OperationQueue * | queue, |
struct GNUNET_TESTBED_Operation * | op, | ||
unsigned int | nres | ||
) |
Add an operation to a queue.
An operation can be in multiple queues at once. Once the operation is inserted into all the queues GNUNET_TESTBED_operation_begin_wait_() has to be called to actually start waiting for the operation to become active.
queue | queue to add the operation to |
op | operation to add to the queue |
nres | the number of units of the resources of queue needed by the operation. Should be greater than 0. |
Definition at line 1184 of file testbed_api_operations.c.
References GNUNET_array_append, GNUNET_assert, QueueEntry::nres, op, and queue().
Referenced by GNUNET_TESTBED_operation_queue_insert_().
void GNUNET_TESTBED_operation_queue_insert_ | ( | struct OperationQueue * | queue, |
struct GNUNET_TESTBED_Operation * | op | ||
) |
Add an operation to a queue.
An operation can be in multiple queues at once. Once the operation is inserted into all the queues GNUNET_TESTBED_operation_begin_wait_() has to be called to actually start waiting for the operation to become active.
queue | queue to add the operation to |
op | operation to add to the queue |
An operation can be in multiple queues at once. Once the operation is inserted into all the queues GNUNET_TESTBED_operation_begin_wait_() has to be called to actually start waiting for the operation to become active. The operation is assumed to take 1 queue resource. Use GNUNET_TESTBED_operation_queue_insert2_() if it requires more than 1
queue | queue to add the operation to |
op | operation to add to the queue |
Definition at line 1210 of file testbed_api_operations.c.
References GNUNET_TESTBED_operation_queue_insert2_(), op, and queue().
Referenced by GNUNET_TESTBED_controller_link(), GNUNET_TESTBED_get_slave_config_(), GNUNET_TESTBED_get_statistics(), GNUNET_TESTBED_host_queue_oc_(), GNUNET_TESTBED_overlay_configure_topology_va(), GNUNET_TESTBED_peer_create(), GNUNET_TESTBED_peer_destroy(), GNUNET_TESTBED_peer_get_information(), GNUNET_TESTBED_peer_manage_service(), GNUNET_TESTBED_peer_start(), GNUNET_TESTBED_peer_stop(), GNUNET_TESTBED_peer_update_configuration(), GNUNET_TESTBED_service_connect(), GNUNET_TESTBED_shutdown_peers(), GST_connection_pool_get_handle(), and GST_neighbour_get_connection().
void GNUNET_TESTBED_operation_begin_wait_ | ( | struct GNUNET_TESTBED_Operation * | op | ) |
Marks the given operation as waiting on the queues.
Once all queues permit the operation to become active, the operation will be activated. The actual activation will occur in a separate task (thus allowing multiple queue insertions to be made without having the first one instantly trigger the operation if the first queue has sufficient resources).
op | the operation to marks as waiting |
Definition at line 1227 of file testbed_api_operations.c.
References change_state(), check_readiness(), GNUNET_assert, op, and OP_STATE_WAITING.
Referenced by GNUNET_TESTBED_controller_link(), GNUNET_TESTBED_get_slave_config_(), GNUNET_TESTBED_get_statistics(), GNUNET_TESTBED_overlay_configure_topology_va(), GNUNET_TESTBED_overlay_connect(), GNUNET_TESTBED_peer_create(), GNUNET_TESTBED_peer_destroy(), GNUNET_TESTBED_peer_get_information(), GNUNET_TESTBED_peer_manage_service(), GNUNET_TESTBED_peer_start(), GNUNET_TESTBED_peer_stop(), GNUNET_TESTBED_peer_update_configuration(), GNUNET_TESTBED_service_connect(), GNUNET_TESTBED_shutdown_peers(), GST_connection_pool_get_handle(), and GST_neighbour_get_connection().
struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_operation_create_ | ( | void * | cls, |
OperationStart | start, | ||
OperationRelease | release | ||
) |
Create an 'operation' to be performed.
cls | closure for the callbacks |
start | function to call to start the operation |
release | function to call to close down the operation |
Definition at line 1028 of file testbed_api_operations.c.
References GNUNET_new, op, OP_STATE_INIT, GNUNET_TESTBED_Operation::release, and start.
Referenced by GNUNET_TESTBED_controller_link(), GNUNET_TESTBED_get_slave_config_(), GNUNET_TESTBED_get_statistics(), GNUNET_TESTBED_overlay_configure_topology_va(), GNUNET_TESTBED_overlay_connect(), GNUNET_TESTBED_peer_create(), GNUNET_TESTBED_peer_destroy(), GNUNET_TESTBED_peer_get_information(), GNUNET_TESTBED_peer_manage_service(), GNUNET_TESTBED_peer_start(), GNUNET_TESTBED_peer_stop(), GNUNET_TESTBED_peer_update_configuration(), GNUNET_TESTBED_service_connect(), GNUNET_TESTBED_shutdown_peers(), GST_connection_pool_get_handle(), and GST_neighbour_get_connection().
void GNUNET_TESTBED_operation_release_ | ( | struct GNUNET_TESTBED_Operation * | op | ) |
An operation is 'done' (was cancelled or finished); remove it from the queues and release associated resources.
op | operation that finished |
Definition at line 1288 of file testbed_api_operations.c.
References OperationQueue::active, GNUNET_assert, GNUNET_free, GNUNET_TESTBED_operation_activate_(), QueueEntry::nres, op, OP_STATE_ACTIVE, OP_STATE_INACTIVE, OP_STATE_INIT, OP_STATE_READY, OP_STATE_WAITING, recheck_waiting(), remove_queue_entry(), rq_remove(), and update_tslots().
Referenced by check_readiness(), GNUNET_TESTBED_operation_done(), and GST_neighbour_list_clean().
void GNUNET_TESTBED_operation_inactivate_ | ( | struct GNUNET_TESTBED_Operation * | op | ) |
Marks an active operation as inactive - the operation will be kept in a ready-to-be-released state and continues to hold resources until another operation contents for them.
op | the operation to be marked as inactive. The operation start callback should have been called before for this operation to mark it as inactive. |
Definition at line 1245 of file testbed_api_operations.c.
References change_state(), GNUNET_assert, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, op, OP_STATE_ACTIVE, OP_STATE_INACTIVE, and recheck_waiting().
Referenced by GST_neighbour_get_connection_cancel(), and GST_neighbour_release_connection().
void GNUNET_TESTBED_operation_activate_ | ( | struct GNUNET_TESTBED_Operation * | op | ) |
Marks and inactive operation as active.
This function should be called to ensure that the oprelease callback will not be called until it is either marked as inactive or released.
op | the operation to be marked as active |
Definition at line 1274 of file testbed_api_operations.c.
References change_state(), GNUNET_assert, op, OP_STATE_ACTIVE, and OP_STATE_INACTIVE.
Referenced by GNUNET_TESTBED_operation_release_(), and trigger_notifications().
void GNUNET_TESTBED_operation_mark_failed | ( | struct GNUNET_TESTBED_Operation * | op | ) |
Marks an operation as failed.
op | the operation to be marked as failed |
Definition at line 1347 of file testbed_api_operations.c.
References GNUNET_YES, and op.
Referenced by handle_op_fail_event().