VLC 4.0.0-dev
Loading...
Searching...
No Matches
Collaboration diagram for Asynchronous/threaded timers:

Macros

#define VLC_TIMER_DISARM   (0)
 
#define VLC_TIMER_FIRE_ONCE   (0)
 

Typedefs

typedef struct vlc_timervlc_timer_t
 Threaded timer handle.
 

Functions

int vlc_timer_create (vlc_timer_t *id, void(*func)(void *), void *data)
 Initializes an asynchronous timer.
 
void vlc_timer_destroy (vlc_timer_t timer)
 Destroys an initialized timer.
 
void vlc_timer_schedule (vlc_timer_t timer, bool absolute, vlc_tick_t value, vlc_tick_t interval)
 Arms or disarms an initialized timer.
 
static void vlc_timer_disarm (vlc_timer_t timer)
 
static void vlc_timer_schedule_asap (vlc_timer_t timer, vlc_tick_t interval)
 
unsigned vlc_timer_getoverrun (vlc_timer_t timer)
 Fetches and resets the overrun counter for a timer.
 

Detailed Description

Macro Definition Documentation

◆ VLC_TIMER_DISARM

#define VLC_TIMER_DISARM   (0)

◆ VLC_TIMER_FIRE_ONCE

#define VLC_TIMER_FIRE_ONCE   (0)

Typedef Documentation

◆ vlc_timer_t

typedef struct vlc_timer* vlc_timer_t

Threaded timer handle.

Function Documentation

◆ vlc_timer_create()

int vlc_timer_create ( vlc_timer_t id,
void(*)(void *)  func,
void *  data 
)

Initializes an asynchronous timer.

Parameters
idpointer to timer to be initialized
funcfunction that the timer will call
dataparameter for the timer function
Returns
0 on success, a system error code otherwise.
Warning
Asynchronous timers are processed from an unspecified thread.
Note
Multiple occurrences of a single interval timer are serialized: they cannot run concurrently.

References vlc_timer::data, vlc_timer::func, vlc_timer::hev, vlc_timer::htimer, vlc_timer::interval, vlc_timer::live, vlc_timer::lock, vlc_timer::overruns, vlc_timer::quit, vlc_timer::reschedule, vlc_timer::t, vlc_timer::thread, vlc_timer::tid, timer_callback(), unlikely, vlc_timer::value, vlc_clone(), vlc_cond_init(), vlc_mutex_init(), vlc_once_begin, vlc_once_complete(), vlc_timer_do(), and vlc_timer_thread().

◆ vlc_timer_destroy()

void vlc_timer_destroy ( vlc_timer_t  timer)

Destroys an initialized timer.

If needed, the timer is first disarmed. Behaviour is undefined if the specified timer is not initialized.

Warning
This function must be called before the timer data can be freed and before the timer callback function can be unmapped/unloaded.
Parameters
timertimer to destroy

References vlc_timer::hev, vlc_timer::htimer, vlc_timer::live, vlc_timer::lock, vlc_timer::quit, vlc_timer::reschedule, vlc_timer::t, vlc_timer::thread, vlc_timer::tid, vlc_cond_signal(), vlc_join(), vlc_mutex_lock(), and vlc_mutex_unlock().

◆ vlc_timer_disarm()

static void vlc_timer_disarm ( vlc_timer_t  timer)
inlinestatic

◆ vlc_timer_getoverrun()

unsigned vlc_timer_getoverrun ( vlc_timer_t  timer)

Fetches and resets the overrun counter for a timer.

This functions returns the number of times that the interval timer should have fired, but the callback was not invoked due to scheduling problems. The call resets the counter to zero.

Parameters
timerinitialized timer
Returns
the timer overrun counter (typically zero)

References vlc_timer::overruns.

◆ vlc_timer_schedule()

void vlc_timer_schedule ( vlc_timer_t  timer,
bool  absolute,
vlc_tick_t  value,
vlc_tick_t  interval 
)

Arms or disarms an initialized timer.

This functions overrides any previous call to itself.

Note
A timer can fire later than requested due to system scheduling limitations. An interval timer can fail to trigger sometimes, either because the system is busy or suspended, or because a previous iteration of the timer is still running. See also vlc_timer_getoverrun().
Parameters
timerinitialized timer
absolutethe timer value origin is the same as vlc_tick_now() if true, the timer value is relative to now if false.
valuezero to disarm the timer, otherwise the initial time to wait before firing the timer.
intervalzero to fire the timer just once, otherwise the timer repetition interval.

References vlc_timer::hev, vlc_timer::htimer, vlc_timer::interval, vlc_timer::lock, MS_FROM_VLC_TICK, MSFTIME_FROM_VLC_TICK, vlc_timer::reschedule, vlc_timer::t, unlikely, vlc_timer::value, vlc_cond_signal(), vlc_mutex_lock(), vlc_mutex_unlock(), vlc_tick_now(), VLC_TIMER_DISARM, and VLC_TIMER_FIRE_ONCE.

Referenced by vlc_timer_disarm(), and vlc_timer_schedule_asap().

◆ vlc_timer_schedule_asap()

static void vlc_timer_schedule_asap ( vlc_timer_t  timer,
vlc_tick_t  interval 
)
inlinestatic

References vlc_timer_schedule().