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

A CommitPolicy which delays commits slightly, trying to batch them. More...

#include <mediascanner/commitpolicy.h>

+ Inheritance diagram for mediascanner::DelayedCommitPolicy:

Public Types

typedef
boost::posix_time::microsec_clock 
Clock
 
typedef
boost::posix_time::time_duration 
Duration
 
typedef boost::posix_time::ptime TimeStamp
 

Public Member Functions

 DelayedCommitPolicy ()
 
 ~DelayedCommitPolicy ()
 
void set_maximum_batch_size (unsigned batch_size)
 Changes the value of maximum_batch_size(). More...
 
unsigned maximum_batch_size () const
 The current maximium batch size after which commits must be performed. More...
 
void set_maximum_delay (Duration delay)
 Changes the value of maximium_delay(). More...
 
Duration maximium_delay () const
 The current maximium timely delay after which commits must be performed. More...
 
bool OnCreate (const std::vector< std::wstring > &media_urls, WritableMediaIndex *media_index)
 This method is called when data has been inserted into the specified media_index. More...
 
bool OnUpdate (const std::vector< std::wstring > &media_urls, WritableMediaIndex *media_index)
 This method is called when data has been updated in the specified media_index. More...
 
bool OnRemove (const std::vector< std::wstring > &media_urls, WritableMediaIndex *media_index)
 This method is called when data has been deleted from the specified media_index. More...
 
- Public Member Functions inherited from mediascanner::CommitPolicy
virtual ~CommitPolicy ()
 

Static Public Member Functions

static unsigned default_maximum_batch_size ()
 The default value of maximum_batch_size() - currently 10. More...
 
static Duration default_maximum_delay ()
 The default value of maximum_delay() - currently 5 seconds. More...
 
- Static Public Member Functions inherited from mediascanner::CommitPolicy
static CommitPolicyPtr default_policy ()
 The default policy - currently an instance of InstantCommitPolicy. More...
 

Protected Member Functions

void UpdateDelayedCommits ()
 
bool PushDelayedCommit (const std::vector< std::wstring > &media_urls, WritableMediaIndex *media_index)
 

Detailed Description

A CommitPolicy which delays commits slightly, trying to batch them.

This policy permits weighting reliability versus performance and wear.

Member Typedef Documentation

typedef boost::posix_time::microsec_clock mediascanner::DelayedCommitPolicy::Clock
typedef boost::posix_time::time_duration mediascanner::DelayedCommitPolicy::Duration
typedef boost::posix_time::ptime mediascanner::DelayedCommitPolicy::TimeStamp

Constructor & Destructor Documentation

mediascanner::DelayedCommitPolicy::DelayedCommitPolicy ( )
mediascanner::DelayedCommitPolicy::~DelayedCommitPolicy ( )

Member Function Documentation

static unsigned mediascanner::DelayedCommitPolicy::default_maximum_batch_size ( )
static

The default value of maximum_batch_size() - currently 10.

static Duration mediascanner::DelayedCommitPolicy::default_maximum_delay ( )
static

The default value of maximum_delay() - currently 5 seconds.

Duration mediascanner::DelayedCommitPolicy::maximium_delay ( ) const

The current maximium timely delay after which commits must be performed.

unsigned mediascanner::DelayedCommitPolicy::maximum_batch_size ( ) const

The current maximium batch size after which commits must be performed.

bool mediascanner::DelayedCommitPolicy::OnCreate ( const std::vector< std::wstring > &  media_urls,
WritableMediaIndex media_index 
)
virtual

This method is called when data has been inserted into the specified media_index.

Policy implementations can now decide when to call CommitPendingChanges().

Parameters
media_urlsThe URLs of the affected media.
media_indexThe affected media index.
Returns
If the change got committed.

Implements mediascanner::CommitPolicy.

bool mediascanner::DelayedCommitPolicy::OnRemove ( const std::vector< std::wstring > &  media_urls,
WritableMediaIndex media_index 
)
virtual

This method is called when data has been deleted from the specified media_index.

Policy implementations can now decide when to call CommitPendingChanges().

Parameters
media_urlsThe URLs of the affected media.
media_indexThe affected media index.
Returns
If the change got committed.

Implements mediascanner::CommitPolicy.

bool mediascanner::DelayedCommitPolicy::OnUpdate ( const std::vector< std::wstring > &  media_urls,
WritableMediaIndex media_index 
)
virtual

This method is called when data has been updated in the specified media_index.

Policy implementations can now decide when to call CommitPendingChanges().

Parameters
media_urlsThe URLs of the affected media.
media_indexThe affected media index.
Returns
If the change got committed.

Implements mediascanner::CommitPolicy.

bool mediascanner::DelayedCommitPolicy::PushDelayedCommit ( const std::vector< std::wstring > &  media_urls,
WritableMediaIndex media_index 
)
protected
void mediascanner::DelayedCommitPolicy::set_maximum_batch_size ( unsigned  batch_size)

Changes the value of maximum_batch_size().

void mediascanner::DelayedCommitPolicy::set_maximum_delay ( Duration  delay)

Changes the value of maximium_delay().

void mediascanner::DelayedCommitPolicy::UpdateDelayedCommits ( )
protected