resonance 1.0.1
Loading...
Searching...
No Matches
task.h
Go to the documentation of this file.
1#pragma once
2
3#include "app/attachment.h"
4#include "os/hxstr.h"
5
13
37class Task : public virtual Attachment {
38public:
40 struct Node {
41 Task *mTask; // +0x00
42 int mState; // +0x04 a TaskState
43 Node *mNext; // +0x08
44 Node *mPrev; // +0x0c
45 };
46
52
62 Task(const Task &other);
63
73 virtual ~Task();
74
83 Task &operator=(const Task &other);
84
96 int Start(int bBlocking);
97
105 int Suspend();
106
114 int Reset();
115
123 int Finish();
124
132 int State() const;
133
141 int InProgress() const;
142
150 float GetProgress();
151
160
168 int GetQuiet();
169
181 static int PollTasks();
182
183protected:
191 virtual float Progress() = 0;
192
198 virtual HxStr Name() const = 0;
199
207 virtual int Quiet();
208
220 virtual int CheckStateChange(int nFrom, int nTo);
221
227 virtual int Poll() = 0;
228
229private:
230 // Link the node in ahead of the ring head, which makes it the last position of a pass.
231 void Link();
232
233 // Take a node out of the ring and make it self-linked again, moving the head along when the
234 // head is the node being removed. 0x004b6490 and every
235 // transition out of kTaskStateRunning inlined a copy of this.
236 static void Unlink(Node *pNode);
237
238 Node *mNode; // +0x04
239};
240
Attachment()
Definition attachment.h:26
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
int InProgress() const
Test whether the task has been started and has not yet finished.
virtual int CheckStateChange(int nFrom, int nTo)
Approve or refuse a lifecycle change.
virtual int Poll()=0
Perform one pass of the task's work.
int GetQuiet()
Test whether the task suppresses its progress report.
Task(const Task &other)
Construct a task with its own fresh node.
virtual float Progress()=0
Report how far the task has progressed.
HxStr GetStatus() const
Read the task's display title.
virtual ~Task()
Unlink the task and release its node.
int Suspend()
Unlink the task and retain its position.
int State() const
Read the task's lifecycle position.
Task & operator=(const Task &other)
Reset the task to kTaskStateIdle.
int Start(int bBlocking)
Begin running the task.
static int PollTasks()
Poll every running task once.
virtual HxStr Name() const =0
Report the task's display title.
float GetProgress()
Read how far the task has progressed.
int Finish()
Retire the task.
virtual int Quiet()
Report whether the task suppresses its progress report.
int Reset()
Return the task to kTaskStateIdle so that it can be started again.
One position in the run ring, allocated separately from the task it refers to.
Definition task.h:40
int mState
Definition task.h:42
Node * mNext
Definition task.h:43
Task * mTask
Definition task.h:41
Node * mPrev
Definition task.h:44
TaskState
The lifecycle position of a Task, stored in its scheduler node.
Definition task.h:7
@ kTaskStateSuspended
Definition task.h:10
@ kTaskStateRunning
Definition task.h:9
@ kTaskStateIdle
Definition task.h:8
@ kTaskStateFinished
Definition task.h:11
Task::Node * g_pRunningTasks
Head of the circular run ring, or null when no task is running.