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
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
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