## prelude-timer

prelude-timer

## Functions

#define | prelude_timer_get_expire()
#define | prelude_timer_get_data()
#define | prelude_timer_get_callback()
#define | prelude_timer_set_expire()
#define | prelude_timer_set_data()
#define | prelude_timer_set_callback()
void | prelude_timer_init ()
void | prelude_timer_init_list ()
void | prelude_timer_reset ()
void | prelude_timer_destroy ()
int | prelude_timer_wake_up ()
void | prelude_timer_flush ()
void | prelude_timer_lock_critical_region ()
void | prelude_timer_unlock_critical_region ()

## Types and Values

| prelude_timer_t

## Description

## Functions

### prelude_timer_get_expire()

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

### prelude_timer_get_data()

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

### prelude_timer_get_callback()

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

### prelude_timer_set_expire()

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

### prelude_timer_set_data()

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

### prelude_timer_set_callback()

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

### prelude_timer_init ()

    void
    prelude_timer_init (prelude_timer_t *timer);

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

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

timer | the timer to destroy. |

### prelude_timer_wake_up ()

    int
    prelude_timer_wake_up (void);

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

#### Returns

Number of second in which `prelude_timer_wake_up()` should be called again.

### 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.

## Types and Values

### prelude_timer_t

    typedef struct {
            prelude_list_t list;

            int expire;
            time_t start_time;

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