diff options
author | lurchi <lurchi@strangeplace.net> | 2017-12-30 21:32:59 +0100 |
---|---|---|
committer | lurchi <lurchi@strangeplace.net> | 2017-12-30 21:32:59 +0100 |
commit | dca8eb9c44dbdfa3fc572dde40c1e0927cfee8db (patch) | |
tree | e0b2a09e6d4777308bb9b30511815b4d5f756891 /src/include/gnunet_scheduler_lib.h | |
parent | 5c8feda7faa01365a1fb6983595ceb65dfe4fb11 (diff) | |
parent | 11f78ccd0b66e08b8d1084cc335daac99d3f6a7e (diff) | |
download | gnunet-dca8eb9c44dbdfa3fc572dde40c1e0927cfee8db.tar.gz gnunet-dca8eb9c44dbdfa3fc572dde40c1e0927cfee8db.zip |
merge branch 'refactoring-scheduler'
Diffstat (limited to 'src/include/gnunet_scheduler_lib.h')
-rw-r--r-- | src/include/gnunet_scheduler_lib.h | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h index a855ab8ab..d2805a685 100644 --- a/src/include/gnunet_scheduler_lib.h +++ b/src/include/gnunet_scheduler_lib.h | |||
@@ -152,14 +152,14 @@ struct GNUNET_SCHEDULER_FdInfo | |||
152 | * NULL if this is about a file handle or if no network | 152 | * NULL if this is about a file handle or if no network |
153 | * handle was given to the scheduler originally. | 153 | * handle was given to the scheduler originally. |
154 | */ | 154 | */ |
155 | struct GNUNET_NETWORK_Handle *fd; | 155 | const struct GNUNET_NETWORK_Handle *fd; |
156 | 156 | ||
157 | /** | 157 | /** |
158 | * GNUnet file handle the event is about, matches @a sock, | 158 | * GNUnet file handle the event is about, matches @a sock, |
159 | * NULL if this is about a network socket or if no network | 159 | * NULL if this is about a network socket or if no network |
160 | * handle was given to the scheduler originally. | 160 | * handle was given to the scheduler originally. |
161 | */ | 161 | */ |
162 | struct GNUNET_DISK_FileHandle *fh; | 162 | const struct GNUNET_DISK_FileHandle *fh; |
163 | 163 | ||
164 | /** | 164 | /** |
165 | * Type of the event that was generated related to @e sock. | 165 | * Type of the event that was generated related to @e sock. |
@@ -216,17 +216,18 @@ struct GNUNET_SCHEDULER_TaskContext | |||
216 | 216 | ||
217 | /** | 217 | /** |
218 | * Function used by event-loop implementations to signal the scheduler | 218 | * Function used by event-loop implementations to signal the scheduler |
219 | * that a particular @a task is ready due to an event of type @a et. | 219 | * that a particular @a task is ready due to an event specified in the |
220 | * et field of @a fdi. | ||
220 | * | 221 | * |
221 | * This function will then queue the task to notify the application | 222 | * This function will then queue the task to notify the application |
222 | * that the task is ready (with the respective priority). | 223 | * that the task is ready (with the respective priority). |
223 | * | 224 | * |
224 | * @param task the task that is ready | 225 | * @param task the task that is ready |
225 | * @param et information about why the task is ready | 226 | * @param fdi information about the related FD |
226 | */ | 227 | */ |
227 | void | 228 | void |
228 | GNUNET_SCHEDULER_task_ready (struct GNUNET_SCHEDULER_Task *task, | 229 | GNUNET_SCHEDULER_task_ready (struct GNUNET_SCHEDULER_Task *task, |
229 | enum GNUNET_SCHEDULER_EventType et); | 230 | struct GNUNET_SCHEDULER_FdInfo *fdi); |
230 | 231 | ||
231 | 232 | ||
232 | /** | 233 | /** |
@@ -241,15 +242,16 @@ struct GNUNET_SCHEDULER_Handle; | |||
241 | * there are tasks left to run just to give other tasks a chance as | 242 | * there are tasks left to run just to give other tasks a chance as |
242 | * well. If we return #GNUNET_YES, the driver should call this | 243 | * well. If we return #GNUNET_YES, the driver should call this |
243 | * function again as soon as possible, while if we return #GNUNET_NO | 244 | * function again as soon as possible, while if we return #GNUNET_NO |
244 | * it must block until the operating system has more work as the | 245 | * it must block until either the operating system has more work (the |
245 | * scheduler has no more work to do right now. | 246 | * scheduler has no more work to do right now) or the timeout set by |
247 | * the scheduler (using the set_wakeup callback) is reached. | ||
246 | * | 248 | * |
247 | * @param sh scheduler handle that was given to the `loop` | 249 | * @param sh scheduler handle that was given to the `loop` |
248 | * @return #GNUNET_OK if there are more tasks that are ready, | 250 | * @return #GNUNET_OK if there are more tasks that are ready, |
249 | * and thus we would like to run more (yield to avoid | 251 | * and thus we would like to run more (yield to avoid |
250 | * blocking other activities for too long) | 252 | * blocking other activities for too long) |
251 | * #GNUNET_NO if we are done running tasks (yield to block) | 253 | * #GNUNET_NO if we are done running tasks (yield to block) |
252 | * #GNUNET_SYSERR on error | 254 | * #GNUNET_SYSERR on error, e.g. no tasks were ready |
253 | */ | 255 | */ |
254 | int | 256 | int |
255 | GNUNET_SCHEDULER_run_from_driver (struct GNUNET_SCHEDULER_Handle *sh); | 257 | GNUNET_SCHEDULER_run_from_driver (struct GNUNET_SCHEDULER_Handle *sh); |
@@ -268,8 +270,11 @@ struct GNUNET_SCHEDULER_Driver | |||
268 | void *cls; | 270 | void *cls; |
269 | 271 | ||
270 | /** | 272 | /** |
271 | * Add a @a task to be run if the conditions given | 273 | * Add a @a task to be run if the conditions specified in the |
272 | * in @a fdi are satisfied. | 274 | * et field of the given @a fdi are satisfied. The et field will |
275 | * be cleared after this call and the driver is expected to set | ||
276 | * the type of the actual event before passing @a fdi to | ||
277 | * #GNUNET_SCHEDULER_task_ready. | ||
273 | * | 278 | * |
274 | * @param cls closure | 279 | * @param cls closure |
275 | * @param task task to add | 280 | * @param task task to add |
@@ -280,21 +285,21 @@ struct GNUNET_SCHEDULER_Driver | |||
280 | int | 285 | int |
281 | (*add)(void *cls, | 286 | (*add)(void *cls, |
282 | struct GNUNET_SCHEDULER_Task *task, | 287 | struct GNUNET_SCHEDULER_Task *task, |
283 | struct GNUNET_SCHEDULER_FdInfo *fdi); | 288 | struct GNUNET_SCHEDULER_FdInfo *fdi); |
284 | 289 | ||
285 | /** | 290 | /** |
286 | * Delete a @a task from the set of tasks to be run. | 291 | * Delete a @a task from the set of tasks to be run. A task may |
292 | * comprise multiple FdInfo entries previously added with the add | ||
293 | * function. The driver is expected to delete them all. | ||
287 | * | 294 | * |
288 | * @param cls closure | 295 | * @param cls closure |
289 | * @param task task to delete | 296 | * @param task task to delete |
290 | * @param fdi conditions to watch for (must match @e add call) | ||
291 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 297 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
292 | * (i.e. @a task or @a fdi do not match prior @e add call) | 298 | * (i.e. @a task does not match prior @e add call) |
293 | */ | 299 | */ |
294 | int | 300 | int |
295 | (*del)(void *cls, | 301 | (*del)(void *cls, |
296 | struct GNUNET_SCHEDULER_Task *task, | 302 | struct GNUNET_SCHEDULER_Task *task); |
297 | const struct GNUNET_SCHEDULER_FdInfo *fdi); | ||
298 | 303 | ||
299 | /** | 304 | /** |
300 | * Set time at which we definitively want to get a wakeup call. | 305 | * Set time at which we definitively want to get a wakeup call. |
@@ -309,7 +314,10 @@ struct GNUNET_SCHEDULER_Driver | |||
309 | /** | 314 | /** |
310 | * Event loop's "main" function, to be called from | 315 | * Event loop's "main" function, to be called from |
311 | * #GNUNET_SCHEDULER_run_with_driver() to actually | 316 | * #GNUNET_SCHEDULER_run_with_driver() to actually |
312 | * launch the loop. | 317 | * launch the loop. The loop should run as long as |
318 | * tasks (added by the add callback) are available | ||
319 | * OR the wakeup time (added by the set_wakeup | ||
320 | * callback) is not FOREVER. | ||
313 | * | 321 | * |
314 | * @param cls closure | 322 | * @param cls closure |
315 | * @param sh scheduler handle to pass to | 323 | * @param sh scheduler handle to pass to |
@@ -359,7 +367,7 @@ GNUNET_SCHEDULER_run_with_driver (const struct GNUNET_SCHEDULER_Driver *driver, | |||
359 | * | 367 | * |
360 | * @return NULL on error | 368 | * @return NULL on error |
361 | */ | 369 | */ |
362 | const struct GNUNET_SCHEDULER_Driver * | 370 | struct GNUNET_SCHEDULER_Driver * |
363 | GNUNET_SCHEDULER_driver_select (void); | 371 | GNUNET_SCHEDULER_driver_select (void); |
364 | 372 | ||
365 | 373 | ||