Skip to content

Commit 2fe2494

Browse files
committed
More skeleton for isRunning()
1 parent c712812 commit 2fe2494

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

src/AsyncTaskStatus.php

+41-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ class AsyncTaskStatus
2727
*/
2828
private bool $isStopped = false;
2929

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+
3036
/**
3137
* Constructs a status object.
3238
* @param string $taskID The task ID of the async task so to check its status.
@@ -57,7 +63,7 @@ public function getEncodedTaskID(): string
5763
*
5864
* Note: when this method detects that the task has stopped running, it will not recheck whether the task has restarted.
5965
* Use a fresh status object to track the (restarted) task.
60-
* @return bool
66+
* @return bool If true, indicates the task is still running.
6167
*/
6268
public function isRunning(): bool
6369
{
@@ -71,4 +77,38 @@ public function isRunning(): bool
7177
}
7278
return $isRunning;
7379
}
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+
}
74114
}

0 commit comments

Comments
 (0)