2 This file is part of GNUnet
3 (C) 2008--2012 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file testbed/testbed_api_operations.h
23 * @brief internal API to access the 'operations' subsystem
24 * @author Christian Grothoff
26 #ifndef NEW_TESTING_API_OPERATIONS_H
27 #define NEW_TESTING_API_OPERATIONS_H
29 #include "gnunet_testbed_service.h"
30 #include "gnunet_helper_lib.h"
34 * Queue of operations where we can only support a certain
35 * number of concurrent operations of a particular type.
37 struct OperationQueue;
41 * Create an operation queue.
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
47 struct OperationQueue *
48 GNUNET_TESTBED_operation_queue_create_ (unsigned int max_active);
52 * Destroy an operation queue. The queue MUST be empty
55 * @param queue queue to destroy
58 GNUNET_TESTBED_operation_queue_destroy_ (struct OperationQueue *queue);
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
70 * @param queue queue to add the operation to
71 * @param operation operation to add to the queue
74 GNUNET_TESTBED_operation_queue_insert_ (struct OperationQueue *queue,
75 struct GNUNET_TESTBED_Operation
80 * Remove an operation from a queue. This can be because the
81 * oeration was active and has completed (and the resources have
82 * been released), or because the operation was cancelled and
83 * thus scheduling the operation is no longer required.
85 * @param queue queue to add the operation to
86 * @param operation operation to add to the queue
89 GNUNET_TESTBED_operation_queue_remove_ (struct OperationQueue *queue,
90 struct GNUNET_TESTBED_Operation
96 * Function to call to start an operation once all
97 * queues the operation is part of declare that the
98 * operation can be activated.
100 * @param cls the closure from GNUNET_TESTBED_operation_create_()
102 typedef void (*OperationStart) (void *cls);
106 * Function to call to cancel an operation (release all associated
107 * resources). This can be because of a call to
108 * "GNUNET_TESTBED_operation_cancel" (before the operation generated
109 * an event) or AFTER the operation generated an event due to a call
110 * to "GNUNET_TESTBED_operation_done". Thus it is not guaranteed that
111 * a callback to the 'OperationStart' preceeds the call to
112 * 'OperationRelease'. Implementations of this function are expected
113 * to clean up whatever state is in 'cls' and release all resources
114 * associated with the operation.
116 * @param cls the closure from GNUNET_TESTBED_operation_create_()
118 typedef void (*OperationRelease) (void *cls);
122 * Create an 'operation' to be performed.
124 * @param cls closure for the callbacks
125 * @param start function to call to start the operation
126 * @param release function to call to close down the operation
127 * @return handle to the operation
129 struct GNUNET_TESTBED_Operation *
130 GNUNET_TESTBED_operation_create_ (void *cls, OperationStart start,
131 OperationRelease release);
135 * An operation is 'done' (was cancelled or finished); remove
136 * it from the queues and release associated resources.
138 * @param operation operation that finished
141 GNUNET_TESTBED_operation_release_ (struct GNUNET_TESTBED_Operation *operation);
145 /* end of testbed_api_operations.h */