@@ -27,6 +27,12 @@ class AsyncTaskStatus
27
27
*/
28
28
private bool $ isStopped = false ;
29
29
30
+ /**
31
+ * The last known PID of the task runner.
32
+ * @var int|null If null, it means the PID is unknown or expired.
33
+ */
34
+ private int |null $ lastKnownPID = null ;
35
+
30
36
/**
31
37
* Constructs a status object.
32
38
* @param string $taskID The task ID of the async task so to check its status.
@@ -57,7 +63,7 @@ public function getEncodedTaskID(): string
57
63
*
58
64
* Note: when this method detects that the task has stopped running, it will not recheck whether the task has restarted.
59
65
* Use a fresh status object to track the (restarted) task.
60
- * @return bool
66
+ * @return bool If true, indicates the task is still running.
61
67
*/
62
68
public function isRunning (): bool
63
69
{
@@ -71,4 +77,38 @@ public function isRunning(): bool
71
77
}
72
78
return $ isRunning ;
73
79
}
80
+
81
+ /**
82
+ * Attepts to prove whether the AsyncTask is still running
83
+ * @return bool If false, then the task is shown to have been stopped.
84
+ */
85
+ private function proveTaskIsRunning (): bool
86
+ {
87
+ if ($ this ->lastKnownPID === null ) {
88
+ // we don't know where the task runner is at; find it!
89
+ return $ this ->findTaskRunnerProcess ();
90
+ }
91
+ // we know the task runner; is it still running?
92
+ return $ this ->observeTaskRunnerProcess ();
93
+ }
94
+
95
+ /**
96
+ * Attempts to find the task runner process (if exists), and writes down its PID.
97
+ * @return bool If true, then the task runner is successfully found.
98
+ */
99
+ private function findTaskRunnerProcess (): bool
100
+ {
101
+ // todo
102
+ return false ;
103
+ }
104
+
105
+ /**
106
+ * Given a previously-noted PID of the task runner, see if the task runner is still alive.
107
+ * @return bool If true, then the task runner is still running.
108
+ */
109
+ private function observeTaskRunnerProcess (): bool
110
+ {
111
+ // todo
112
+ return false ;
113
+ }
74
114
}
0 commit comments