aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_operations.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-05-05 18:51:21 +0000
committerChristian Grothoff <christian@grothoff.org>2012-05-05 18:51:21 +0000
commit201817c66fb0eb1d477085091bb30e3b1e832e9e (patch)
tree052d32a9a245c76565f59ee2fa1d45950e6bb96e /src/testbed/testbed_api_operations.h
parentaa4d975205a4f8da4a4dcfd9d7274db8138a9d07 (diff)
downloadgnunet-201817c66fb0eb1d477085091bb30e3b1e832e9e.tar.gz
gnunet-201817c66fb0eb1d477085091bb30e3b1e832e9e.zip
-draft structure for operation queues
Diffstat (limited to 'src/testbed/testbed_api_operations.h')
-rw-r--r--src/testbed/testbed_api_operations.h98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/testbed/testbed_api_operations.h b/src/testbed/testbed_api_operations.h
index 8d478bf95..4c888d52d 100644
--- a/src/testbed/testbed_api_operations.h
+++ b/src/testbed/testbed_api_operations.h
@@ -30,5 +30,103 @@
30#include "gnunet_helper_lib.h" 30#include "gnunet_helper_lib.h"
31 31
32 32
33/**
34 * Queue of operations where we can only support a certain
35 * number of concurrent operations of a particular type.
36 */
37struct OperationQueue;
38
39
40/**
41 * Create an operation queue.
42 *
43 * @param max_active maximum number of operations in this
44 * queue that can be active in parallel at the same time
45 * @return handle to the queue
46 */
47struct OperationQueue *
48GNUNET_TESTBED_operation_queue_create_ (unsigned int max_active);
49
50
51/**
52 * Destroy an operation queue. The queue MUST be empty
53 * at this time.
54 *
55 * @param queue queue to destroy
56 */
57void
58GNUNET_TESTBED_operation_queue_destroy_ (struct OperationQueue *queue);
59
60
61/**
62 * Add an operation to a queue. An operation can be in multiple
63 * queues at once. Once all queues permit the operation to become
64 * active, the operation will be activated. The actual activation
65 * will occur in a separate task (thus allowing multiple queue
66 * insertions to be made without having the first one instantly
67 * trigger the operation if the first queue has sufficient
68 * resources).
69 *
70 * @param queue queue to add the operation to
71 * @param operation operation to add to the queue
72 */
73void
74GNUNET_TESTBED_operation_queue_insert_ (struct OperationQueue *queue,
75 struct GNUNET_TESTBED_Operation *operation);
76
77
78/**
79 * Remove an operation from a queue. This can be because the
80 * oeration was active and has completed (and the resources have
81 * been released), or because the operation was cancelled and
82 * thus scheduling the operation is no longer required.
83 *
84 * @param queue queue to add the operation to
85 * @param operation operation to add to the queue
86 */
87void
88GNUNET_TESTBED_operation_queue_remove_ (struct OperationQueue *queue,
89 struct GNUNET_TESTBED_Operation *operation);
90
91
92
93/**
94 * Function to call to start an operation once all
95 * queues the operation is part of declare that the
96 * operation can be activated.
97 */
98typedef void (*OperationStart)(void *cls);
99
100
101/**
102 * Function to call to cancel an operation (release all associated
103 * resources). This can be because of a call to
104 * "GNUNET_TESTBED_operation_cancel" (before the operation generated
105 * an event) or AFTER the operation generated an event due to a call
106 * to "GNUNET_TESTBED_operation_done". Thus it is not guaranteed that
107 * a callback to the 'OperationStart' preceeds the call to
108 * 'OperationRelease'. Implementations of this function are expected
109 * to clean up whatever state is in 'cls' and release all resources
110 * associated with the operation.
111 */
112typedef void (*OperationRelease)(void *cls);
113
114
115/**
116 * Create an 'operation' to be performed.
117 *
118 * @param cls closure for the callbacks
119 * @param start function to call to start the operation
120 * @param release function to call to close down the operation
121 * @param ... FIXME
122 * @return handle to the operation
123 */
124struct GNUNET_TESTBED_Operation *
125GNUNET_TESTBED_operation_create_ (void *cls,
126 OperationStart start,
127 OperationRelease release,
128 ...);
129
130
33#endif 131#endif
34/* end of testbed_api_operations.h */ 132/* end of testbed_api_operations.h */