Ubuntu TV Media Scanner
A centralized index for removable media content.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Static Public Member Functions | List of all members
mediascanner::Timeout Class Reference

The Timeout class provides access to GLib's timeout mechanism. More...

#include <mediascanner/glibutils.h>

+ Inheritance diagram for mediascanner::Timeout:

Public Types

typedef
boost::posix_time::time_duration 
Duration
 This type describes time durations. More...
 
- Public Types inherited from mediascanner::Source
typedef std::function< bool()> SourceFunction
 The signature of a regular idle source. More...
 
typedef std::function< void()> OneCallFunction
 The signature of a single-call idle source. More...
 

Static Public Member Functions

static unsigned Add (Duration interval, const SourceFunction &function, int priority=G_PRIORITY_DEFAULT_IDLE)
 Adds a new timeout function to the event loop. More...
 
static unsigned AddOnce (Duration interval, const OneCallFunction &function, int priority=G_PRIORITY_DEFAULT_IDLE)
 Adds a new timeout function to the event loop that is called exactly once. More...
 
- Static Public Member Functions inherited from mediascanner::Source
static bool Remove (unsigned id)
 Removes an event source handler. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from mediascanner::Source
static gboolean on_source_function (gpointer data)
 
static gboolean on_one_call_function (gpointer data)
 

Detailed Description

The Timeout class provides access to GLib's timeout mechanism.

It manages functions which get called whenever a given time interval has passed.

Note that timeout functions might get delayed if the event loop gets blocked by other sources.

See Also
Idle

Member Typedef Documentation

typedef boost::posix_time::time_duration mediascanner::Timeout::Duration

This type describes time durations.

Note that the duration's resolution impacts which resolution the timeout source will have.

Member Function Documentation

static unsigned mediascanner::Timeout::Add ( Duration  interval,
const SourceFunction function,
int  priority = G_PRIORITY_DEFAULT_IDLE 
)
inlinestatic

Adds a new timeout function to the event loop.

The timeout gets automatically removed from the list of event sources if function returns false.

Note that the exact timeout mechanism is selected upon the interval parameter's resolution. If the resolution is in seconds (or even less granular) timeout sources of seconds precision are created. Otherwise the sources have milliseconds resolution.

Parameters
intervalThe time between calls to the function.
functionThe function to be called on idle.
priorityThe priority of the idle source.
Returns
The identifier (greater than 0) of the event source.
See Also
AddOnce(), Source::Remove()
static unsigned mediascanner::Timeout::AddOnce ( Duration  interval,
const OneCallFunction function,
int  priority = G_PRIORITY_DEFAULT_IDLE 
)
inlinestatic

Adds a new timeout function to the event loop that is called exactly once.

After its invocation the timeout gets automatically removed from the list of event sources if function returns false.

Note that the exact timeout mechanism is selected upon the interval parameter's resolution. If the resolution is in seconds (or even less granular) timeout sources of seconds precision are created. Otherwise the sources have milliseconds resolution.

Parameters
intervalThe time between calls to the function.
functionThe function to be called on idle.
priorityThe priority of the idle source.
Returns
The identifier (greater than 0) of the event source.
See Also
AddOnce(), Source::Remove()