fixing drq code
[oweals/gnunet.git] / src / fs / gnunet-service-fs_drq.h
1 /*
2      This file is part of GNUnet.
3      (C) 2009, 2010 Christian Grothoff (and other contributing authors)
4
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 2, or (at your
8      option) any later version.
9
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.
14
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.
19 */
20
21 /**
22  * @file fs/gnunet-service-fs_drq.h
23  * @brief queueing of requests to the datastore service
24  * @author Christian Grothoff
25  */
26 #ifndef GNUNET_SERVICE_FS_DRQ_H
27 #define GNUNET_SERVICE_FS_DRQ_H
28
29 #include "gnunet_datastore_service.h"
30 #include "gnunet_util_lib.h"
31
32
33 /**
34  * Handle for pending, abortable requests for the datastore.
35  */
36 struct DatastoreRequestQueue;
37
38
39 /**
40  * Iterate over the results for a particular key
41  * in the datastore.  The iterator will only be called
42  * once initially; if the first call did contain a
43  * result, further results can be obtained by calling
44  * "GNUNET_DATASTORE_get_next" with the given argument.
45  *
46  * @param key maybe NULL (to match all entries)
47  * @param type desired type, 0 for any
48  * @param iter function to call on each matching value;
49  *        will be called once with a NULL value at the end
50  * @param iter_cls closure for iter
51  * @param timeout how long to wait at most for a response
52  * @param immediate should this be queued immediately at
53  *        the head of the queue (irrespecitive of the timeout)?
54  */
55 struct DatastoreRequestQueue *
56 GNUNET_FS_drq_get (const GNUNET_HashCode * key,
57                    uint32_t type,
58                    GNUNET_DATASTORE_Iterator iter, 
59                    void *iter_cls,
60                    struct GNUNET_TIME_Relative timeout,
61                    int immediate);
62
63
64
65 void
66 GNUNET_FS_drq_get_cancel (struct DatastoreRequestQueue *drq);
67
68
69 /**
70  * Function called to trigger obtaining the next result
71  * from the datastore.  Must be called (directly or indirectly)
72  * from the 'iter' callback given to 'GNUNET_FS_drq_get'.
73  * Not calling 'get_next' means no other datastore
74  * interactions (other than remove) will happen.
75  * 
76  * @param more GNUNET_YES to get more results, GNUNET_NO to abort
77  *        iteration (with a final call to "iter" with key/data == NULL).
78  */
79 void
80 GNUNET_FS_drq_get_next (int more);
81
82
83 /**
84  * Explicitly remove some content from the database.
85  * The "cont"inuation will be called with status
86  * "GNUNET_OK" if content was removed, "GNUNET_NO"
87  * if no matching entry was found and "GNUNET_SYSERR"
88  * on all other types of errors.
89  *
90  * @param key key for the value
91  * @param size number of bytes in data
92  * @param data content stored
93  * @param cont continuation to call when done
94  * @param cont_cls closure for cont
95  * @param timeout how long to wait at most for a response
96  */
97 void
98 GNUNET_FS_drq_remove (const GNUNET_HashCode *key,
99                       uint32_t size, const void *data,
100                       GNUNET_DATASTORE_ContinuationWithStatus cont,
101                       void *cont_cls,
102                       struct GNUNET_TIME_Relative timeout);
103
104
105
106 /**
107  * Explicitly remove some content from the database.
108  * The "cont"inuation will be called with status
109  * "GNUNET_OK" if content was removed, "GNUNET_NO"
110  * if no matching entry was found and "GNUNET_SYSERR"
111  * on all other types of errors.
112  *
113  * @param key key for the value
114  * @param size number of bytes in data
115  * @param data content stored
116  * @param cont continuation to call when done
117  * @param cont_cls closure for cont
118  * @param timeout how long to wait at most for a response
119  */
120 void
121 GNUNET_FS_drq_remove (const GNUNET_HashCode *key,
122                       uint32_t size, const void *data,
123                       GNUNET_DATASTORE_ContinuationWithStatus cont,
124                       void *cont_cls,
125                       struct GNUNET_TIME_Relative timeout);
126 /**
127  * Setup datastore request queues.
128  * 
129  * @param s scheduler to use
130  * @param c configuration to use
131  * @return GNUNET_OK on success
132  */
133 int 
134 GNUNET_FS_drq_init (struct GNUNET_SCHEDULER_Handle *s,
135                     const struct GNUNET_CONFIGURATION_Handle *c);
136
137
138
139 /* end of gnunet-service-fs_drq.h */
140 #endif