Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
1070482e4639d99ff8db34c6c6673d34546ce1c9
[simgrid.git] / include / gras / timer.h
1 /* timer - delayed and repetitive tasks                                     */
2 /* module's public interface exported to end user.                          */
3
4 /* Copyright (c) 2005 Martin Quinson. All rights reserved.                  */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #ifndef GRAS_TIMER_H
10 #define GRAS_TIMER_H
11
12 #include "xbt/misc.h"
13
14 SG_BEGIN_DECL()
15
16 /** @addtogroup GRAS_timer
17  *  @brief Delayed and repetitive tasks
18  *
19  *  This is how to have a specific function called only once after the
20  *  specified amount of time or a function executed every 5 mn until it gets 
21  *  removed. In the UNIX world, this is comparable to <tt>at</tt> and 
22  *  <tt>cron</tt>.
23  *
24  *  Note that this is very soft timers: the execution of the processes won't
25  *  get interrupted at all. This is on purpose: the GRAS programming model
26  *  is distributed sequential, so that users don't have to deal with mutexes
27  *  and such within a specific process.
28  *
29  *  Timers are served by the gras_handle() function: if there is an elapsed 
30  *  timer, the associated code gets executed before any incomming connexion 
31  *  are checked. 
32  *
33  *  The section \ref GRAS_ex_timer constitutes a perfect example of these features.
34  * 
35  *  @{
36  */
37 XBT_PUBLIC(void) gras_timer_delay(double delay, void_f_void_t action);
38 XBT_PUBLIC(void) gras_timer_repeat(double interval, void_f_void_t action);
39
40 XBT_PUBLIC(void) gras_timer_cancel_delay(double interval,
41                                          void_f_void_t action);
42 XBT_PUBLIC(void) gras_timer_cancel_repeat(double interval,
43                                           void_f_void_t action);
44
45 XBT_PUBLIC(void) gras_timer_cancel_delay_all(void);
46 XBT_PUBLIC(void) gras_timer_cancel_repeat_all(void);
47
48 XBT_PUBLIC(void) gras_timer_cancel_all(void);
49
50 /** @} */
51
52 SG_END_DECL()
53 #endif /* GRAS_TIMER_H */