MailCommon::ScheduledTask Class

class MailCommon::ScheduledTask
Header: #include <MailCommon/JobScheduler>
CMake: find_package(KPim6MailCommon REQUIRED)
target_link_libraries(mytarget PRIVATE KPim6::MailCommon)

Public Functions

ScheduledTask(const Akonadi::Collection &folder, bool immediate)
virtual ~ScheduledTask()
Akonadi::Collection folder() const
bool isImmediate() const
virtual MailCommon::ScheduledJob *run() = 0
virtual int taskTypeId() const = 0

Detailed Description

A scheduled task is some information about a folder job that should be run later. As long as it's not running, it's called a "task", i.e. something that needs to be done. Tasks are managed by the JobScheduler.

Member Function Documentation

ScheduledTask::ScheduledTask(const Akonadi::Collection &folder, bool immediate)

Creates a scheduled task for a given folder. If immediate is true, the scheduler will run this task as soon as possible (but won't interrupt a currently running job for it).

folder The Akonadi collection to perform the task on immediate Whether the task should be run immediately

[virtual noexcept] ScheduledTask::~ScheduledTask()

Destroys the scheduled task.

Akonadi::Collection ScheduledTask::folder() const

The folder which this task is supposed to handle, 0 if it was deleted meanwhile.

Returns The collection for this task

bool ScheduledTask::isImmediate() const

Returns whether this task should be run immediately.

Returns True if the task is immediate, false otherwise

[pure virtual] MailCommon::ScheduledJob *ScheduledTask::run()

Run this task, i.e. create a job for it. Important: the job's execute() method must either call open() on the folder or storage immediately, or abort (deleting itself). Usually, that job should also be cancellable. Otherwise (if the open() is delayed) an unrelated open() could happen first and mess things up. If for some reason (e.g. a folder is deleted) nothing should be done, return 0.

Returns A ScheduledJob to execute, or nullptr if nothing should be done

[pure virtual] int ScheduledTask::taskTypeId() const

An identifier for the type of task (a bit like QListViewItem::rtti). This allows to automatically prevent two identical tasks from being scheduled for the same folder. To circumvent this feature and make every task unique, return 0 here.

Returns A unique task type ID, or 0 for unique tasks