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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
23 * Asynchronous operations; register callbacks for operations and call them when a response arrives.
25 * @author Gabor X Toth
31 #include "gnunet_util_lib.h"
36 struct GNUNET_OP_Handle;
40 * Create new operations handle.
42 struct GNUNET_OP_Handle *
47 * Destroy operations handle.
50 GNUNET_OP_destroy (struct GNUNET_OP_Handle *h);
54 * Get a unique operation ID to distinguish between asynchronous requests.
59 * @return Operation ID to use.
62 GNUNET_OP_get_next_id (struct GNUNET_OP_Handle *h);
66 * Find operation by ID.
71 * Operation ID to look up.
72 * @param[out] result_cb
73 * If an operation was found, its result callback is returned here.
75 * If an operation was found, its closure is returned here.
79 * @return #GNUNET_YES if an operation was found,
80 * #GNUNET_NO if not found.
83 GNUNET_OP_get (struct GNUNET_OP_Handle *h,
85 GNUNET_ResultCallback *result_cb,
91 * Add a new operation.
96 * Function to call with the result of the operation.
98 * Closure for @a result_cb.
102 * @return ID of the new operation.
105 GNUNET_OP_add (struct GNUNET_OP_Handle *h,
106 GNUNET_ResultCallback result_cb,
112 * Call the result callback of an operation and remove it.
119 * Result of the operation.
121 * Data result of the operation.
127 * @return #GNUNET_YES if the operation was found and removed,
128 * #GNUNET_NO if the operation was not found.
131 GNUNET_OP_result (struct GNUNET_OP_Handle *h,
140 * Remove / cancel an operation.
147 * @return #GNUNET_YES if the operation was found and removed,
148 * #GNUNET_NO if the operation was not found.
151 GNUNET_OP_remove (struct GNUNET_OP_Handle *h,
155 #endif // GNUNET_OP_H