Logo AND Algorithmique Numérique Distribuée

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