spunQ_Cron Class Reference

Responsible for managing repetitive tasks. More...

List of all members.

Static Public Member Functions

static priorityString ($numericPriority)
 Gives a human-readable string desccription for a numeric priority value.
static registerTask ($callback, $interval, $priority=self::PRIORITY_DEFAULT)
 Registers a cron task.
static tick (spunQ_IMutex $mutex=NULL)
 Processes all tasks in order of priority.

Public Attributes

const PRIORITY_SPUNQ = 1
 Reserved priority level for spunQ.
const PRIORITY_MANDATORY = 2
 Priority level for tasks that must be done as soon as possible.
const PRIORITY_IMPORTANT = 4
 Priority level for tasks that should be done quickly.
const PRIORITY_DEFAULT = 6
 Default priority level.
const PRIORITY_UNIMPORTANT = 8
 Priority level for tasks that don't have to complete.
const PRIORITY_NEGLIGABLE = 10
 Priority level for the most unimportant tasks.

Static Protected Member Functions

static taskIsDue ($previousTimestamp, $currentTimestamp, $interval)
 Checks if a task needs to be performed.

Static Protected Attributes

static $tasks = array()
 The tasks that have been registered via registerTask().


Detailed Description

Responsible for managing repetitive tasks.

The priorities for the tasks determine the order in which they are processed. More important ones come first, so that any errors generated in other processes don't bother them.

Definition at line 9 of file Cron.class.php.


Member Function Documentation

static spunQ_Cron::priorityString ( numericPriority  )  [static]

Gives a human-readable string desccription for a numeric priority value.

Parameters:
$numericPriority A numeric priority value.
Returns:
string

Definition at line 62 of file Cron.class.php.

static spunQ_Cron::registerTask ( callback,
interval,
priority = self::PRIORITY_DEFAULT 
) [static]

Registers a cron task.

Parameters:
$interval Time interval in seconds that this task needs to be executed in.
$priority Either of the PRIORITY_* constants.
$callback A callback to execute when this task needs to be performed.
Returns:
void

Definition at line 87 of file Cron.class.php.

static spunQ_Cron::taskIsDue ( previousTimestamp,
currentTimestamp,
interval 
) [static, protected]

Checks if a task needs to be performed.

Every task is considered due at timestamps divisible by their interval.

Parameters:
$previousTimestamp Timestamp when tick() was last invoked.
$currentTimestamp Value returned by time(). Kept as argument to maintain atomicity.
interval The interval of the task.
Returns:
boolean

Definition at line 150 of file Cron.class.php.

static spunQ_Cron::tick ( spunQ_IMutex mutex = NULL  )  [static]

Processes all tasks in order of priority.

Returns:
void

Definition at line 102 of file Cron.class.php.


Member Data Documentation

spunQ_Cron::$tasks = array() [static, protected]

The tasks that have been registered via registerTask().

This is a nested array containing priorities as keys at the outer-most level, intervals after that, which then contain the tasks. So a task with priority x and an update interval of y can be found in the array $tasks[x][y].

Type:
array<array<array<callback>>>

Definition at line 55 of file Cron.class.php.

Default priority level.

See class documentation for more information on priorities.

Definition at line 33 of file Cron.class.php.

Priority level for tasks that should be done quickly.

See class documentation for more information on priorities.

Definition at line 27 of file Cron.class.php.

Priority level for tasks that must be done as soon as possible.

See class documentation for more information on priorities.

Definition at line 21 of file Cron.class.php.

Priority level for the most unimportant tasks.

See class documentation for more information on priorities.

Definition at line 45 of file Cron.class.php.

Reserved priority level for spunQ.

See class documentation for more information on priorities.

Definition at line 15 of file Cron.class.php.

Priority level for tasks that don't have to complete.

See class documentation for more information on priorities.

Definition at line 39 of file Cron.class.php.


The documentation for this class was generated from the following file:

Generated on Fri Jul 1 11:12:39 2011 for spunQ3 by  doxygen 1.5.9