diff options
Diffstat (limited to 'src/include/gnunet_scheduler_lib.h')
-rw-r--r-- | src/include/gnunet_scheduler_lib.h | 93 |
1 files changed, 27 insertions, 66 deletions
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h index b39feb926..774f2f4bc 100644 --- a/src/include/gnunet_scheduler_lib.h +++ b/src/include/gnunet_scheduler_lib.h | |||
@@ -35,12 +35,6 @@ extern "C" | |||
35 | #endif | 35 | #endif |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | |||
39 | /** | ||
40 | * Opaque handle for the scheduling service. | ||
41 | */ | ||
42 | struct GNUNET_SCHEDULER_Handle; | ||
43 | |||
44 | /** | 38 | /** |
45 | * Opaque reference to a task. | 39 | * Opaque reference to a task. |
46 | */ | 40 | */ |
@@ -167,12 +161,6 @@ enum GNUNET_SCHEDULER_Priority | |||
167 | */ | 161 | */ |
168 | struct GNUNET_SCHEDULER_TaskContext | 162 | struct GNUNET_SCHEDULER_TaskContext |
169 | { | 163 | { |
170 | |||
171 | /** | ||
172 | * Scheduler running the task | ||
173 | */ | ||
174 | struct GNUNET_SCHEDULER_Handle *sched; | ||
175 | |||
176 | /** | 164 | /** |
177 | * Reason why the task is run now | 165 | * Reason why the task is run now |
178 | */ | 166 | */ |
@@ -229,10 +217,8 @@ void GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls); | |||
229 | * cause all tasks to run (as soon as possible, respecting | 217 | * cause all tasks to run (as soon as possible, respecting |
230 | * priorities and prerequisite tasks). Note that tasks | 218 | * priorities and prerequisite tasks). Note that tasks |
231 | * scheduled AFTER this call may still be delayed arbitrarily. | 219 | * scheduled AFTER this call may still be delayed arbitrarily. |
232 | * | ||
233 | * @param sched the scheduler | ||
234 | */ | 220 | */ |
235 | void GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched); | 221 | void GNUNET_SCHEDULER_shutdown (); |
236 | 222 | ||
237 | 223 | ||
238 | /** | 224 | /** |
@@ -241,14 +227,12 @@ void GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched); | |||
241 | * dropped (if the decision should be made based on the number of | 227 | * dropped (if the decision should be made based on the number of |
242 | * tasks ready to run). | 228 | * tasks ready to run). |
243 | * | 229 | * |
244 | * @param sched scheduler to query | 230 | * * @param p priority-level to query, use KEEP to query the level |
245 | * @param p priority-level to query, use KEEP to query the level | ||
246 | * of the current task, use COUNT to get the sum over | 231 | * of the current task, use COUNT to get the sum over |
247 | * all priority levels | 232 | * all priority levels |
248 | * @return number of tasks pending right now | 233 | * @return number of tasks pending right now |
249 | */ | 234 | */ |
250 | unsigned int GNUNET_SCHEDULER_get_load (struct GNUNET_SCHEDULER_Handle *sched, | 235 | unsigned int GNUNET_SCHEDULER_get_load (enum GNUNET_SCHEDULER_Priority p); |
251 | enum GNUNET_SCHEDULER_Priority p); | ||
252 | 236 | ||
253 | 237 | ||
254 | /** | 238 | /** |
@@ -256,23 +240,20 @@ unsigned int GNUNET_SCHEDULER_get_load (struct GNUNET_SCHEDULER_Handle *sched, | |||
256 | * started. Will return the same value as | 240 | * started. Will return the same value as |
257 | * the GNUNET_SCHEDULER_TaskContext's reason field. | 241 | * the GNUNET_SCHEDULER_TaskContext's reason field. |
258 | * | 242 | * |
259 | * @param sched scheduler to query | 243 | * * @return reason(s) why the current task is run |
260 | * @return reason(s) why the current task is run | ||
261 | */ | 244 | */ |
262 | enum GNUNET_SCHEDULER_Reason | 245 | enum GNUNET_SCHEDULER_Reason |
263 | GNUNET_SCHEDULER_get_reason (struct GNUNET_SCHEDULER_Handle *sched); | 246 | GNUNET_SCHEDULER_get_reason (); |
264 | 247 | ||
265 | 248 | ||
266 | /** | 249 | /** |
267 | * Cancel the task with the specified identifier. | 250 | * Cancel the task with the specified identifier. |
268 | * The task must not yet have run. | 251 | * The task must not yet have run. |
269 | * | 252 | * |
270 | * @param sched scheduler to use | 253 | * * @param task id of the task to cancel |
271 | * @param task id of the task to cancel | ||
272 | * @return the closure of the callback of the cancelled task | 254 | * @return the closure of the callback of the cancelled task |
273 | */ | 255 | */ |
274 | void *GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched, | 256 | void *GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_TaskIdentifier task); |
275 | GNUNET_SCHEDULER_TaskIdentifier task); | ||
276 | 257 | ||
277 | 258 | ||
278 | /** | 259 | /** |
@@ -280,14 +261,12 @@ void *GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched, | |||
280 | * similar to the other "add" functions except that there is no delay | 261 | * similar to the other "add" functions except that there is no delay |
281 | * and the reason code can be specified. | 262 | * and the reason code can be specified. |
282 | * | 263 | * |
283 | * @param sched scheduler to use | 264 | * * @param task main function of the task |
284 | * @param task main function of the task | ||
285 | * @param task_cls closure of task | 265 | * @param task_cls closure of task |
286 | * @param reason reason for task invocation | 266 | * @param reason reason for task invocation |
287 | */ | 267 | */ |
288 | void | 268 | void |
289 | GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, | 269 | GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task, |
290 | GNUNET_SCHEDULER_Task task, | ||
291 | void *task_cls, | 270 | void *task_cls, |
292 | enum GNUNET_SCHEDULER_Reason reason); | 271 | enum GNUNET_SCHEDULER_Reason reason); |
293 | 272 | ||
@@ -297,8 +276,7 @@ GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, | |||
297 | * has completed. It will be run with the priority of the calling | 276 | * has completed. It will be run with the priority of the calling |
298 | * task. | 277 | * task. |
299 | * | 278 | * |
300 | * @param sched scheduler to use | 279 | * * @param prerequisite_task run this task after the task with the given |
301 | * @param prerequisite_task run this task after the task with the given | ||
302 | * task identifier completes (and any of our other | 280 | * task identifier completes (and any of our other |
303 | * conditions, such as delay, read or write-readiness | 281 | * conditions, such as delay, read or write-readiness |
304 | * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency | 282 | * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency |
@@ -310,8 +288,7 @@ GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, | |||
310 | * only valid until "task" is started! | 288 | * only valid until "task" is started! |
311 | */ | 289 | */ |
312 | GNUNET_SCHEDULER_TaskIdentifier | 290 | GNUNET_SCHEDULER_TaskIdentifier |
313 | GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched, | 291 | GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, |
314 | GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, | ||
315 | GNUNET_SCHEDULER_Task task, | 292 | GNUNET_SCHEDULER_Task task, |
316 | void *task_cls); | 293 | void *task_cls); |
317 | 294 | ||
@@ -319,16 +296,14 @@ GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched, | |||
319 | /** | 296 | /** |
320 | * Schedule a new task to be run with a specified priority. | 297 | * Schedule a new task to be run with a specified priority. |
321 | * | 298 | * |
322 | * @param sched scheduler to use | 299 | * * @param prio how important is the new task? |
323 | * @param prio how important is the new task? | ||
324 | * @param task main function of the task | 300 | * @param task main function of the task |
325 | * @param task_cls closure of task | 301 | * @param task_cls closure of task |
326 | * @return unique task identifier for the job | 302 | * @return unique task identifier for the job |
327 | * only valid until "task" is started! | 303 | * only valid until "task" is started! |
328 | */ | 304 | */ |
329 | GNUNET_SCHEDULER_TaskIdentifier | 305 | GNUNET_SCHEDULER_TaskIdentifier |
330 | GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle *sched, | 306 | GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio, |
331 | enum GNUNET_SCHEDULER_Priority prio, | ||
332 | GNUNET_SCHEDULER_Task task, | 307 | GNUNET_SCHEDULER_Task task, |
333 | void *task_cls); | 308 | void *task_cls); |
334 | 309 | ||
@@ -337,15 +312,13 @@ GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle *sched, | |||
337 | * Schedule a new task to be run as soon as possible. The task | 312 | * Schedule a new task to be run as soon as possible. The task |
338 | * will be run with the priority of the calling task. | 313 | * will be run with the priority of the calling task. |
339 | * | 314 | * |
340 | * @param sched scheduler to use | 315 | * * @param task main function of the task |
341 | * @param task main function of the task | ||
342 | * @param task_cls closure of task | 316 | * @param task_cls closure of task |
343 | * @return unique task identifier for the job | 317 | * @return unique task identifier for the job |
344 | * only valid until "task" is started! | 318 | * only valid until "task" is started! |
345 | */ | 319 | */ |
346 | GNUNET_SCHEDULER_TaskIdentifier | 320 | GNUNET_SCHEDULER_TaskIdentifier |
347 | GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched, | 321 | GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_Task task, |
348 | GNUNET_SCHEDULER_Task task, | ||
349 | void *task_cls); | 322 | void *task_cls); |
350 | 323 | ||
351 | 324 | ||
@@ -354,8 +327,7 @@ GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched, | |||
354 | * will be scheduled for execution once the delay has expired. It | 327 | * will be scheduled for execution once the delay has expired. It |
355 | * will be run with the priority of the calling task. | 328 | * will be run with the priority of the calling task. |
356 | * | 329 | * |
357 | * @param sched scheduler to use | 330 | * * @param delay when should this operation time out? Use |
358 | * @param delay when should this operation time out? Use | ||
359 | * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | 331 | * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" |
360 | * @param task main function of the task | 332 | * @param task main function of the task |
361 | * @param task_cls closure of task | 333 | * @param task_cls closure of task |
@@ -363,8 +335,7 @@ GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched, | |||
363 | * only valid until "task" is started! | 335 | * only valid until "task" is started! |
364 | */ | 336 | */ |
365 | GNUNET_SCHEDULER_TaskIdentifier | 337 | GNUNET_SCHEDULER_TaskIdentifier |
366 | GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched, | 338 | GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, |
367 | struct GNUNET_TIME_Relative delay, | ||
368 | GNUNET_SCHEDULER_Task task, | 339 | GNUNET_SCHEDULER_Task task, |
369 | void *task_cls); | 340 | void *task_cls); |
370 | 341 | ||
@@ -377,8 +348,7 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched, | |||
377 | * socket operation is ready. It will be run with the priority of | 348 | * socket operation is ready. It will be run with the priority of |
378 | * the calling task. | 349 | * the calling task. |
379 | * | 350 | * |
380 | * @param sched scheduler to use | 351 | * * @param delay when should this operation time out? Use |
381 | * @param delay when should this operation time out? Use | ||
382 | * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | 352 | * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" |
383 | * @param rfd read file-descriptor | 353 | * @param rfd read file-descriptor |
384 | * @param task main function of the task | 354 | * @param task main function of the task |
@@ -387,8 +357,7 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched, | |||
387 | * only valid until "task" is started! | 357 | * only valid until "task" is started! |
388 | */ | 358 | */ |
389 | GNUNET_SCHEDULER_TaskIdentifier | 359 | GNUNET_SCHEDULER_TaskIdentifier |
390 | GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle *sched, | 360 | GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, |
391 | struct GNUNET_TIME_Relative delay, | ||
392 | struct GNUNET_NETWORK_Handle *rfd, | 361 | struct GNUNET_NETWORK_Handle *rfd, |
393 | GNUNET_SCHEDULER_Task task, | 362 | GNUNET_SCHEDULER_Task task, |
394 | void *task_cls); | 363 | void *task_cls); |
@@ -402,8 +371,7 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle *sched, | |||
402 | * socket operation is ready. It will be run with the priority of | 371 | * socket operation is ready. It will be run with the priority of |
403 | * the calling task. | 372 | * the calling task. |
404 | * | 373 | * |
405 | * @param sched scheduler to use | 374 | * * @param delay when should this operation time out? Use |
406 | * @param delay when should this operation time out? Use | ||
407 | * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | 375 | * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" |
408 | * @param wfd write file-descriptor | 376 | * @param wfd write file-descriptor |
409 | * @param task main function of the task | 377 | * @param task main function of the task |
@@ -412,8 +380,7 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle *sched, | |||
412 | * only valid until "task" is started! | 380 | * only valid until "task" is started! |
413 | */ | 381 | */ |
414 | GNUNET_SCHEDULER_TaskIdentifier | 382 | GNUNET_SCHEDULER_TaskIdentifier |
415 | GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle *sched, | 383 | GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, |
416 | struct GNUNET_TIME_Relative delay, | ||
417 | struct GNUNET_NETWORK_Handle *wfd, | 384 | struct GNUNET_NETWORK_Handle *wfd, |
418 | GNUNET_SCHEDULER_Task task, | 385 | GNUNET_SCHEDULER_Task task, |
419 | void *task_cls); | 386 | void *task_cls); |
@@ -427,8 +394,7 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle *sched, | |||
427 | * socket operation is ready. It will be run with the priority of | 394 | * socket operation is ready. It will be run with the priority of |
428 | * the calling task. | 395 | * the calling task. |
429 | * | 396 | * |
430 | * @param sched scheduler to use | 397 | * * @param delay when should this operation time out? Use |
431 | * @param delay when should this operation time out? Use | ||
432 | * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | 398 | * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" |
433 | * @param rfd read file-descriptor | 399 | * @param rfd read file-descriptor |
434 | * @param task main function of the task | 400 | * @param task main function of the task |
@@ -437,8 +403,7 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle *sched, | |||
437 | * only valid until "task" is started! | 403 | * only valid until "task" is started! |
438 | */ | 404 | */ |
439 | GNUNET_SCHEDULER_TaskIdentifier | 405 | GNUNET_SCHEDULER_TaskIdentifier |
440 | GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle *sched, | 406 | GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, |
441 | struct GNUNET_TIME_Relative delay, | ||
442 | const struct GNUNET_DISK_FileHandle *rfd, | 407 | const struct GNUNET_DISK_FileHandle *rfd, |
443 | GNUNET_SCHEDULER_Task task, | 408 | GNUNET_SCHEDULER_Task task, |
444 | void *task_cls); | 409 | void *task_cls); |
@@ -452,8 +417,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle *sched, | |||
452 | * socket operation is ready. It will be run with the priority of | 417 | * socket operation is ready. It will be run with the priority of |
453 | * the calling task. | 418 | * the calling task. |
454 | * | 419 | * |
455 | * @param sched scheduler to use | 420 | * * @param delay when should this operation time out? Use |
456 | * @param delay when should this operation time out? Use | ||
457 | * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | 421 | * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" |
458 | * @param wfd write file-descriptor | 422 | * @param wfd write file-descriptor |
459 | * @param task main function of the task | 423 | * @param task main function of the task |
@@ -462,8 +426,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle *sched, | |||
462 | * only valid until "task" is started! | 426 | * only valid until "task" is started! |
463 | */ | 427 | */ |
464 | GNUNET_SCHEDULER_TaskIdentifier | 428 | GNUNET_SCHEDULER_TaskIdentifier |
465 | GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched, | 429 | GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, |
466 | struct GNUNET_TIME_Relative delay, | ||
467 | const struct GNUNET_DISK_FileHandle *wfd, | 430 | const struct GNUNET_DISK_FileHandle *wfd, |
468 | GNUNET_SCHEDULER_Task task, | 431 | GNUNET_SCHEDULER_Task task, |
469 | void *task_cls); | 432 | void *task_cls); |
@@ -486,8 +449,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched, | |||
486 | * || shutdown-active) | 449 | * || shutdown-active) |
487 | * </code> | 450 | * </code> |
488 | * | 451 | * |
489 | * @param sched scheduler to use | 452 | * * @param prio how important is this task? |
490 | * @param prio how important is this task? | ||
491 | * @param prerequisite_task run this task after the task with the given | 453 | * @param prerequisite_task run this task after the task with the given |
492 | * task identifier completes (and any of our other | 454 | * task identifier completes (and any of our other |
493 | * conditions, such as delay, read or write-readiness | 455 | * conditions, such as delay, read or write-readiness |
@@ -503,8 +465,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched, | |||
503 | * only valid until "task" is started! | 465 | * only valid until "task" is started! |
504 | */ | 466 | */ |
505 | GNUNET_SCHEDULER_TaskIdentifier | 467 | GNUNET_SCHEDULER_TaskIdentifier |
506 | GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle *sched, | 468 | GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, |
507 | enum GNUNET_SCHEDULER_Priority prio, | ||
508 | GNUNET_SCHEDULER_TaskIdentifier | 469 | GNUNET_SCHEDULER_TaskIdentifier |
509 | prerequisite_task, | 470 | prerequisite_task, |
510 | struct GNUNET_TIME_Relative delay, | 471 | struct GNUNET_TIME_Relative delay, |