Provides facilities for scheduling tasks. Each task is a serializable object that can be scheduled to be run now, at some time in the future, or periodically. For the methods that run at some delayed point in the future, the delay is taken from the moment when the scheduling method was called.
For all methods on TaskManager
, if the instance of Task
provided does not implement ManagedObject
then the TaskManager
will persist the Task
until it finishes. This provides durability, and is particularly convenient for simple tasks that the developer doesn't wish to manage and remove manually. However, if the Task
does implement ManagedObject
, then it's assumed that the Task
is already managed, and it is up to the developer to remove it from the DataManager
when finished.
If the instance of Task
provided to any of these methods is an instance of a class that has the RunWithNewIdentity
annotation then that task will be run with a new owning identity. Periodic tasks will use this same owning identity for all recurrences. In practical terms, this means that the system will be able to recognize these tasks as distinct behavior from other tasks in the system.
Note that there is no assumed ordering provided by implementations of this interface. If two tasks are scheduled in a given transaction, it is undefined which task will run or complete first. Likewise, if a task is scheduled and then a second scheduled in a later transaction, there is no guarantee that the task scheduled in the previous transaction will complete first. If any ordering or dependency is required, this should be implemented within the tasks themselves.
@see AppContext#getTaskManager
@see Task
@see RunWithNewIdentity