schedule_job uses seconds to support time values larger than 49 days
[strongswan.git] / src / charon / processing / scheduler.h
1 /*
2 * Copyright (C) 2005-2007 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * $Id$
17 */
18
19 /**
20 * @defgroup scheduler scheduler
21 * @{ @ingroup processing
22 */
23
24 #ifndef SCHEDULER_H_
25 #define SCHEDULER_H_
26
27 typedef struct scheduler_t scheduler_t;
28
29 #include <sys/time.h>
30
31 #include <library.h>
32 #include <processing/jobs/job.h>
33
34 /**
35 * The scheduler queues and executes timed events.
36 *
37 * The scheduler stores timed events and passes them to the processor.
38 */
39 struct scheduler_t {
40
41 /**
42 * Adds a event to the queue, using a relative time offset in s.
43 *
44 * @param job job to schedule
45 * @param time relative time to schedule job, in s
46 */
47 void (*schedule_job) (scheduler_t *this, job_t *job, u_int32_t s);
48
49 /**
50 * Adds a event to the queue, using a relative time offset in ms.
51 *
52 * @param job job to schedule
53 * @param time relative time to schedule job, in ms
54 */
55 void (*schedule_job_ms) (scheduler_t *this, job_t *job, u_int32_t ms);
56
57 /**
58 * Adds a event to the queue, using an absolut time.
59 *
60 * @param job job to schedule
61 * @param time absolut time to schedule job
62 */
63 void (*schedule_job_tv) (scheduler_t *this, job_t *job, timeval_t tv);
64
65 /**
66 * Returns number of jobs scheduled.
67 *
68 * @return number of scheduled jobs
69 */
70 u_int (*get_job_load) (scheduler_t *this);
71
72 /**
73 * Destroys a scheduler object.
74 */
75 void (*destroy) (scheduler_t *this);
76 };
77
78 /**
79 * Create a scheduler.
80 *
81 * @return scheduler_t object
82 */
83 scheduler_t *scheduler_create(void);
84
85 #endif /** SCHEDULER_H_ @}*/