2 This file is part of GNUnet.
3 Copyright (C) 2016 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * Asynchronous operations; register callbacks for operations and call them when a response arrives.
23 * @author Gabor X Toth
29 #include "gnunet_util_lib.h"
34 struct GNUNET_OP_Handle;
38 * Create new operations handle.
40 struct GNUNET_OP_Handle *
45 * Destroy operations handle.
48 GNUNET_OP_destroy (struct GNUNET_OP_Handle *h);
52 * Get a unique operation ID to distinguish between asynchronous requests.
57 * @return Operation ID to use.
60 GNUNET_OP_get_next_id (struct GNUNET_OP_Handle *h);
64 * Find operation by ID.
69 * Operation ID to look up.
70 * @param[out] result_cb
71 * If an operation was found, its result callback is returned here.
73 * If an operation was found, its closure is returned here.
77 * @return #GNUNET_YES if an operation was found,
78 * #GNUNET_NO if not found.
81 GNUNET_OP_get (struct GNUNET_OP_Handle *h,
83 GNUNET_ResultCallback *result_cb,
89 * Add a new operation.
94 * Function to call with the result of the operation.
96 * Closure for @a result_cb.
100 * @return ID of the new operation.
103 GNUNET_OP_add (struct GNUNET_OP_Handle *h,
104 GNUNET_ResultCallback result_cb,
110 * Call the result callback of an operation and remove it.
117 * Result of the operation.
119 * Data result of the operation.
125 * @return #GNUNET_YES if the operation was found and removed,
126 * #GNUNET_NO if the operation was not found.
129 GNUNET_OP_result (struct GNUNET_OP_Handle *h,
138 * Remove / cancel an operation.
145 * @return #GNUNET_YES if the operation was found and removed,
146 * #GNUNET_NO if the operation was not found.
149 GNUNET_OP_remove (struct GNUNET_OP_Handle *h,
153 #endif // GNUNET_OP_H