prelude-timer

## prelude-timer prelude-timer |

## Synopsis

                        prelude_timer_t;
    #define             prelude_timer_get_expire            (timer)
    #define             prelude_timer_get_data              (timer)
    #define             prelude_timer_get_callback          (timer)
    #define             prelude_timer_set_expire            (timer, x)
    #define             prelude_timer_set_data              (timer, x)
    #define             prelude_timer_set_callback          (timer, x)
    void                prelude_timer_init                  (prelude_timer_t *timer);
    void                prelude_timer_init_list             (prelude_timer_t *timer);
    void                prelude_timer_reset                 (prelude_timer_t *timer);
    void                prelude_timer_destroy               (prelude_timer_t *timer);
    void                prelude_timer_wake_up               (void);
    void                prelude_timer_flush                 (void);
    void                prelude_timer_lock_critical_region  (void);
    void                prelude_timer_unlock_critical_region
                                                            (void);

## Description

## Details

### prelude_timer_t

    typedef struct {
            prelude_list_t list;

            int expire;
            time_t start_time;

            void *data;
            void (*function)(void *data);
    } prelude_timer_t;

### prelude_timer_get_expire()

    #define prelude_timer_get_expire(timer) (timer)->expire

`timer` : |

### prelude_timer_get_data()

    #define prelude_timer_get_data(timer) (timer)->data

`timer` : |

### prelude_timer_get_callback()

    #define prelude_timer_get_callback(timer) (timer)->function

`timer` : |

### prelude_timer_set_expire()

    #define prelude_timer_set_expire(timer, x) prelude_timer_get_expire((timer)) = (x)

`timer` : |
`x` : |

### prelude_timer_set_data()

    #define prelude_timer_set_data(timer, x) prelude_timer_get_data((timer)) = (x)

`timer` : |
`x` : |

### prelude_timer_set_callback()

    #define prelude_timer_set_callback(timer, x) prelude_timer_get_callback((timer)) = (x)

`timer` : |
`x` : |

### prelude_timer_init ()

    void                prelude_timer_init                  (prelude_timer_t *timer);

Initialize a timer (add it to the timer list).

`timer` : | timer to initialize.

### prelude_timer_init_list ()

    void                prelude_timer_init_list             (prelude_timer_t *timer);

Initialize `timer` list member. This is useful if you're going to call `prelude_timer_destroy()` on timer for which `prelude_timer_init()` was never called.

`timer` : | Pointer to a prelude_timer_t object.

### prelude_timer_reset ()

    void                prelude_timer_reset                 (prelude_timer_t *timer);

Reset timer 'timer', as if it was just started.

`timer` : | the timer to reset.

### prelude_timer_destroy ()

    void                prelude_timer_destroy               (prelude_timer_t *timer);

Destroy the timer 'timer', this remove it from the active timer list.

`timer` : | the timer to destroy.

### prelude_timer_wake_up ()

    void                prelude_timer_wake_up               (void);

Wake up timer that need it. This function should be called every second to work properly.

### prelude_timer_flush ()

    void                prelude_timer_flush                 (void);

Expire every timer.

### prelude_timer_lock_critical_region ()

    void                prelude_timer_lock_critical_region  (void);

Deactivate timer wake-up until `timer_unlock_critical_region()` is called.

### prelude_timer_unlock_critical_region ()

    void                prelude_timer_unlock_critical_region
                                                            (void);

Reactivate timer wake-up after `timer_lock_critical_regions()` has been called.