CWIS Developer Documentation
|
Task manager component of top-level framework for web applications. More...
Public Member Functions | |
QueueTask ($Callback, $Parameters=NULL, $Priority=self::PRIORITY_LOW, $Description="") | |
Add task to queue. More... | |
QueueUniqueTask ($Callback, $Parameters=NULL, $Priority=self::PRIORITY_LOW, $Description="") | |
Add task to queue if not already in queue or currently running. More... | |
TaskIsInQueue ($Callback, $Parameters=NULL) | |
Check if task is already in queue or currently running. More... | |
GetTaskQueueSize ($Priority=NULL) | |
Retrieve current number of tasks in queue. More... | |
GetQueuedTaskList ($Count=100, $Offset=0) | |
Retrieve list of tasks currently in queue. More... | |
GetQueuedTaskCount ($Callback=NULL, $Parameters=NULL, $Priority=NULL, $Description=NULL) | |
Get number of queued tasks that match supplied values. More... | |
GetRunningTaskList ($Count=100, $Offset=0) | |
Retrieve list of tasks currently running. More... | |
GetRunningTaskCount () | |
Retrieve count of tasks currently running. More... | |
GetOrphanedTaskList ($Count=100, $Offset=0) | |
Retrieve list of tasks currently orphaned. More... | |
GetOrphanedTaskCount () | |
Retrieve current number of orphaned tasks. More... | |
ReQueueOrphanedTask ($TaskId, $NewPriority=NULL) | |
Move orphaned task back into queue. More... | |
RequeueCurrentTask ($NewValue=TRUE) | |
Set whether to requeue the currently-running background task when it completes. More... | |
DeleteTask ($TaskId) | |
Remove task from task queues. More... | |
GetTask ($TaskId) | |
Retrieve task info from queue (either running or queued tasks). More... | |
TaskExecutionEnabled ($NewValue=DB_NOVALUE, $Persistent=FALSE) | |
Get/set whether automatic task execution is enabled. More... | |
MaxTasks ($NewValue=DB_NOVALUE, $Persistent=FALSE) | |
Get/set maximum number of tasks to have running simultaneously. More... | |
GetCurrentBackgroundPriority () | |
Determine current priority if running in background. More... | |
GetNextHigherBackgroundPriority ($Priority=NULL) | |
Get next higher possible background task priority. More... | |
GetNextLowerBackgroundPriority ($Priority=NULL) | |
Get next lower possible background task priority. More... | |
RunQueuedTasks () | |
Run any queued background tasks until either remaining PHP execution time or available memory run too low. More... | |
Static Public Member Functions | |
static | GetTaskCallbackSynopsis (array $TaskInfo) |
Get printable synopsis for task callback. More... | |
Public Attributes | |
const | PRIORITY_HIGH = 1 |
Highest priority. More... | |
const | PRIORITY_MEDIUM = 2 |
Medium (default) priority. More... | |
const | PRIORITY_LOW = 3 |
Lower priority. More... | |
const | PRIORITY_BACKGROUND = 4 |
Lowest priority. More... | |
Task manager component of top-level framework for web applications.
Definition at line 14 of file AFTaskManager.php.
AFTaskManager::DeleteTask | ( | $TaskId | ) |
Remove task from task queues.
int | $TaskId | Task ID. |
Definition at line 303 of file AFTaskManager.php.
AFTaskManager::GetCurrentBackgroundPriority | ( | ) |
Determine current priority if running in background.
Definition at line 483 of file AFTaskManager.php.
Referenced by GetNextHigherBackgroundPriority(), and GetNextLowerBackgroundPriority().
AFTaskManager::GetNextHigherBackgroundPriority | ( | $Priority = NULL | ) |
Get next higher possible background task priority.
If already at the highest priority, the same value is returned.
int | $Priority | Background priority (PRIORITY_ value). (OPTIONAL, defaults to current priority if running in background, or NULL if running in foreground) |
Definition at line 498 of file AFTaskManager.php.
References GetCurrentBackgroundPriority().
AFTaskManager::GetNextLowerBackgroundPriority | ( | $Priority = NULL | ) |
Get next lower possible background task priority.
If already at the lowest priority, the same value is returned.
int | $Priority | Background priority (PRIORITY_ value). (OPTIONAL, defaults to current priority if running in background, or NULL if running in foreground) |
Definition at line 521 of file AFTaskManager.php.
References GetCurrentBackgroundPriority().
AFTaskManager::GetOrphanedTaskCount | ( | ) |
Retrieve current number of orphaned tasks.
Definition at line 256 of file AFTaskManager.php.
AFTaskManager::GetOrphanedTaskList | ( | $Count = 100 , |
|
$Offset = 0 |
|||
) |
Retrieve list of tasks currently orphaned.
int | $Count | Number to retrieve. (OPTIONAL, defaults to 100) |
int | $Offset | Offset into queue to start retrieval. (OPTIONAL) |
Definition at line 244 of file AFTaskManager.php.
AFTaskManager::GetQueuedTaskCount | ( | $Callback = NULL , |
|
$Parameters = NULL , |
|||
$Priority = NULL , |
|||
$Description = NULL |
|||
) |
Get number of queued tasks that match supplied values.
Tasks will not be counted if the values do not match exactly, so callbacks with methods for different objects (even of the same class) will not match.
callback | $Callback | Function or method to call to perform task. (OPTIONAL) |
array | $Parameters | Array containing parameters to pass to function or method. Pass in empty array to match tasks with no parameters. (OPTIONAL) |
int | $Priority | Priority to assign to task. (OPTIONAL) |
string | $Description | Text description of task. (OPTIONAL) |
Definition at line 183 of file AFTaskManager.php.
Referenced by GetTaskQueueSize().
AFTaskManager::GetQueuedTaskList | ( | $Count = 100 , |
|
$Offset = 0 |
|||
) |
Retrieve list of tasks currently in queue.
int | $Count | Number to retrieve. (OPTIONAL, defaults to 100) |
int | $Offset | Offset into queue to start retrieval. (OPTIONAL) |
Definition at line 164 of file AFTaskManager.php.
AFTaskManager::GetRunningTaskCount | ( | ) |
Retrieve count of tasks currently running.
Definition at line 229 of file AFTaskManager.php.
Referenced by RunQueuedTasks().
AFTaskManager::GetRunningTaskList | ( | $Count = 100 , |
|
$Offset = 0 |
|||
) |
Retrieve list of tasks currently running.
int | $Count | Number to retrieve. (OPTIONAL, defaults to 100) |
int | $Offset | Offset into queue to start retrieval. (OPTIONAL) |
Definition at line 217 of file AFTaskManager.php.
AFTaskManager::GetTask | ( | $TaskId | ) |
Retrieve task info from queue (either running or queued tasks).
int | $TaskId | Task ID. |
Definition at line 319 of file AFTaskManager.php.
Referenced by RunQueuedTasks().
|
static |
Get printable synopsis for task callback.
Any string values in the callback parameter list will be escaped with htmlspecialchars().
array | $TaskInfo | Array of task info as returned by GetTask(). |
Definition at line 396 of file AFTaskManager.php.
AFTaskManager::GetTaskQueueSize | ( | $Priority = NULL | ) |
Retrieve current number of tasks in queue.
int | $Priority | Priority of tasks. (OPTIONAL, defaults to all priorities) |
Definition at line 152 of file AFTaskManager.php.
References GetQueuedTaskCount().
Referenced by RunQueuedTasks().
AFTaskManager::MaxTasks | ( | $NewValue = DB_NOVALUE , |
|
$Persistent = FALSE |
|||
) |
Get/set maximum number of tasks to have running simultaneously.
int | $NewValue | New setting for max number of tasks. (OPTIONAL) |
bool | $Persistent | If TRUE the new value will be saved (i.e. persistent across page loads), otherwise the value will apply to just the current page load. (OPTIONAL, defaults to FALSE) |
Definition at line 384 of file AFTaskManager.php.
Referenced by RunQueuedTasks().
AFTaskManager::QueueTask | ( | $Callback, | |
$Parameters = NULL , |
|||
$Priority = self::PRIORITY_LOW , |
|||
$Description = "" |
|||
) |
Add task to queue.
The Callback parameters is the PHP "callback" type. If $Callback refers to a function (rather than an object method) that function must be available in a global scope on all pages or must be loadable by ApplicationFramework::LoadFunction(). If $Priority is out-of-bounds, it wil be normalized to be within bounds.
callback | $Callback | Function or method to call to perform task. |
array | $Parameters | Array containing parameters to pass to function or method. (OPTIONAL, pass NULL for no parameters) |
int | $Priority | Priority to assign to task. (OPTIONAL, defaults to PRIORITY_LOW) |
string | $Description | Text description of task. (OPTIONAL) |
Definition at line 54 of file AFTaskManager.php.
Referenced by QueueUniqueTask().
AFTaskManager::QueueUniqueTask | ( | $Callback, | |
$Parameters = NULL , |
|||
$Priority = self::PRIORITY_LOW , |
|||
$Description = "" |
|||
) |
Add task to queue if not already in queue or currently running.
If task is already in queue with a lower priority than specified, the task's priority will be increased to the new value. The Callback parameter is the PHP "callback" type. If $Callback refers to a function (rather than an object method) that function must be available in a global scope on all pages or must be loadable by ApplicationFramework::LoadFunction(). If $Priority is out-of-bounds, it wil be normalized to be within bounds.
callback | $Callback | Function or method to call to perform task. |
array | $Parameters | Array containing parameters to pass to function or method. (OPTIONAL, pass NULL for no parameters) |
int | $Priority | Priority to assign to task. (OPTIONAL, defaults to PRIORITY_LOW) |
string | $Description | Text description of task. (OPTIONAL) |
Definition at line 88 of file AFTaskManager.php.
References QueueTask(), and TaskIsInQueue().
AFTaskManager::RequeueCurrentTask | ( | $NewValue = TRUE | ) |
Set whether to requeue the currently-running background task when it completes.
bool | $NewValue | If TRUE, current task will be requeued. (OPTIONAL, defaults to TRUE) |
Definition at line 293 of file AFTaskManager.php.
Referenced by RunQueuedTasks().
AFTaskManager::ReQueueOrphanedTask | ( | $TaskId, | |
$NewPriority = NULL |
|||
) |
Move orphaned task back into queue.
int | $TaskId | Task ID. |
int | $NewPriority | New priority for task being requeued. (OPTIONAL) |
Definition at line 269 of file AFTaskManager.php.
AFTaskManager::RunQueuedTasks | ( | ) |
Run any queued background tasks until either remaining PHP execution time or available memory run too low.
Definition at line 539 of file AFTaskManager.php.
References DB_NOVALUE, ApplicationFramework\GetFreeMemory(), ApplicationFramework\GetPercentFreeMemory(), ApplicationFramework\GetPhpMemoryLimit(), GetRunningTaskCount(), GetTask(), GetTaskQueueSize(), Database\INT_MAX_VALUE, ApplicationFramework\LOGLVL_DEBUG, MaxTasks(), and RequeueCurrentTask().
AFTaskManager::TaskExecutionEnabled | ( | $NewValue = DB_NOVALUE , |
|
$Persistent = FALSE |
|||
) |
Get/set whether automatic task execution is enabled.
(This does not prevent tasks from being manually executed.)
bool | $NewValue | TRUE to enable or FALSE to disable. (OPTIONAL) |
bool | $Persistent | If TRUE the new value will be saved (i.e. persistent across page loads), otherwise the value will apply to just the current page load. (OPTIONAL, defaults to FALSE) |
Definition at line 370 of file AFTaskManager.php.
AFTaskManager::TaskIsInQueue | ( | $Callback, | |
$Parameters = NULL |
|||
) |
Check if task is already in queue or currently running.
When no $Parameters value is specified the task is checked against any other entries with the same $Callback.
callback | $Callback | Function or method to call to perform task. |
array | $Parameters | Array containing parameters to pass to function or method. (OPTIONAL) |
Definition at line 129 of file AFTaskManager.php.
Referenced by QueueUniqueTask().
const AFTaskManager::PRIORITY_BACKGROUND = 4 |
Lowest priority.
Definition at line 39 of file AFTaskManager.php.
const AFTaskManager::PRIORITY_HIGH = 1 |
Highest priority.
Definition at line 33 of file AFTaskManager.php.
const AFTaskManager::PRIORITY_LOW = 3 |
Lower priority.
Definition at line 37 of file AFTaskManager.php.
const AFTaskManager::PRIORITY_MEDIUM = 2 |
Medium (default) priority.
Definition at line 35 of file AFTaskManager.php.