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 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.
18 * Asynchronous operations; register callbacks for operations and call them when a response arrives.
20 * @author Gabor X Toth
26 #include "gnunet_util_lib.h"
31 struct GNUNET_OP_Handle;
35 * Create new operations handle.
37 struct GNUNET_OP_Handle *
42 * Destroy operations handle.
45 GNUNET_OP_destroy (struct GNUNET_OP_Handle *h);
49 * Get a unique operation ID to distinguish between asynchronous requests.
54 * @return Operation ID to use.
57 GNUNET_OP_get_next_id (struct GNUNET_OP_Handle *h);
61 * Find operation by ID.
66 * Operation ID to look up.
67 * @param[out] result_cb
68 * If an operation was found, its result callback is returned here.
70 * If an operation was found, its closure is returned here.
74 * @return #GNUNET_YES if an operation was found,
75 * #GNUNET_NO if not found.
78 GNUNET_OP_get (struct GNUNET_OP_Handle *h,
80 GNUNET_ResultCallback *result_cb,
86 * Add a new operation.
91 * Function to call with the result of the operation.
93 * Closure for @a result_cb.
97 * @return ID of the new operation.
100 GNUNET_OP_add (struct GNUNET_OP_Handle *h,
101 GNUNET_ResultCallback result_cb,
107 * Call the result callback of an operation and remove it.
114 * Result of the operation.
116 * Data result of the operation.
122 * @return #GNUNET_YES if the operation was found and removed,
123 * #GNUNET_NO if the operation was not found.
126 GNUNET_OP_result (struct GNUNET_OP_Handle *h,
135 * Remove / cancel an operation.
142 * @return #GNUNET_YES if the operation was found and removed,
143 * #GNUNET_NO if the operation was not found.
146 GNUNET_OP_remove (struct GNUNET_OP_Handle *h,
150 #endif // GNUNET_OP_H