[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/classes/task/ -> manager.php (summary)

Scheduled and adhoc task management.

Copyright: 2013 Damyon Wiese
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 667 lines (24 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

manager:: (20 methods):
  load_default_scheduled_tasks_for_component()
  reset_scheduled_tasks_for_component()
  queue_adhoc_task()
  configure_scheduled_task()
  record_from_scheduled_task()
  record_from_adhoc_task()
  adhoc_task_from_record()
  scheduled_task_from_record()
  load_scheduled_tasks_for_component()
  get_scheduled_task()
  get_default_scheduled_task()
  get_all_scheduled_tasks()
  get_next_adhoc_task()
  get_next_scheduled_task()
  adhoc_task_failed()
  adhoc_task_complete()
  scheduled_task_failed()
  scheduled_task_complete()
  clear_static_caches()
  static_caches_cleared_since()


Class: manager  - X-Ref

Collection of task related methods.

Some locking rules for this class:
All changes to scheduled tasks must be protected with both - the global cron lock and the lock
for the specific scheduled task (in that order). Locks must be released in the reverse order.
load_default_scheduled_tasks_for_component($componentname)   X-Ref
Given a component name, will load the list of tasks in the db/tasks.php file for that component.

param: string $componentname - The name of the component to fetch the tasks for.
return: \core\task\scheduled_task[] - List of scheduled tasks for this component.

reset_scheduled_tasks_for_component($componentname)   X-Ref
Update the database to contain a list of scheduled task for a component.
The list of scheduled tasks is taken from @load_scheduled_tasks_for_component.
Will throw exceptions for any errors.

param: string $componentname - The frankenstyle component name.

queue_adhoc_task(adhoc_task $task)   X-Ref
Queue an adhoc task to run in the background.

param: \core\task\adhoc_task $task - The new adhoc task information to store.
return: boolean - True if the config was saved.

configure_scheduled_task(scheduled_task $task)   X-Ref
Change the default configuration for a scheduled task.
The list of scheduled tasks is taken from {@link load_scheduled_tasks_for_component}.

param: \core\task\scheduled_task $task - The new scheduled task information to store.
return: boolean - True if the config was saved.

record_from_scheduled_task($task)   X-Ref
Utility method to create a DB record from a scheduled task.

param: \core\task\scheduled_task $task
return: \stdClass

record_from_adhoc_task($task)   X-Ref
Utility method to create a DB record from an adhoc task.

param: \core\task\adhoc_task $task
return: \stdClass

adhoc_task_from_record($record)   X-Ref
Utility method to create an adhoc task from a DB record.

param: \stdClass $record
return: \core\task\adhoc_task

scheduled_task_from_record($record)   X-Ref
Utility method to create a task from a DB record.

param: \stdClass $record
return: \core\task\scheduled_task

load_scheduled_tasks_for_component($componentname)   X-Ref
Given a component name, will load the list of tasks from the scheduled_tasks table for that component.
Do not execute tasks loaded from this function - they have not been locked.

param: string $componentname - The name of the component to load the tasks for.
return: \core\task\scheduled_task[]

get_scheduled_task($classname)   X-Ref
This function load the scheduled task details for a given classname.

param: string $classname
return: \core\task\scheduled_task or false

get_default_scheduled_task($classname)   X-Ref
This function load the default scheduled task details for a given classname.

param: string $classname
return: \core\task\scheduled_task or false

get_all_scheduled_tasks()   X-Ref
This function will return a list of all the scheduled tasks that exist in the database.

return: \core\task\scheduled_task[]

get_next_adhoc_task($timestart)   X-Ref
This function will dispatch the next adhoc task in the queue. The task will be handed out
with an open lock - possibly on the entire cron process. Make sure you call either
{@link adhoc_task_failed} or {@link adhoc_task_complete} to release the lock and reschedule the task.

param: int $timestart
return: \core\task\adhoc_task or null if not found

get_next_scheduled_task($timestart)   X-Ref
This function will dispatch the next scheduled task in the queue. The task will be handed out
with an open lock - possibly on the entire cron process. Make sure you call either
{@link scheduled_task_failed} or {@link scheduled_task_complete} to release the lock and reschedule the task.

param: int $timestart - The start of the cron process - do not repeat any tasks that have been run more recently than this.
return: \core\task\scheduled_task or null

adhoc_task_failed(adhoc_task $task)   X-Ref
This function indicates that an adhoc task was not completed successfully and should be retried.

param: \core\task\adhoc_task $task

adhoc_task_complete(adhoc_task $task)   X-Ref
This function indicates that an adhoc task was completed successfully.

param: \core\task\adhoc_task $task

scheduled_task_failed(scheduled_task $task)   X-Ref
This function indicates that a scheduled task was not completed successfully and should be retried.

param: \core\task\scheduled_task $task

scheduled_task_complete(scheduled_task $task)   X-Ref
This function indicates that a scheduled task was completed successfully and should be rescheduled.

param: \core\task\scheduled_task $task

clear_static_caches()   X-Ref
This function is used to indicate that any long running cron processes should exit at the
next opportunity and restart. This is because something (e.g. DB changes) has changed and
the static caches may be stale.


static_caches_cleared_since($starttime)   X-Ref
Return true if the static caches have been cleared since $starttime.

param: int $starttime The time this process started.
return: boolean True if static caches need resetting.



Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1