From 7aa5698486d3a60d2bf1d9f5b6d3d6093c78dafc Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Wed, 7 Jun 2023 20:09:34 +0200 Subject: [PATCH] improved Processhandle --- src/kernel/ps/ProcessHandle.hx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/kernel/ps/ProcessHandle.hx b/src/kernel/ps/ProcessHandle.hx index 99cace2..7adcadf 100644 --- a/src/kernel/ps/ProcessHandle.hx +++ b/src/kernel/ps/ProcessHandle.hx @@ -21,6 +21,8 @@ class ProcessHandle { private var closeFutureResolev: Bool -> Void; private final windowContexts: Array = []; private final cbLinks:Array = []; + private final deferFuncs:Array Void> = []; + private var hasExited: Bool = false; @:allow(kernel.ps.ProcessManager) private function new(config: HandleConfig,pid: PID) { @@ -42,12 +44,15 @@ class ProcessHandle { } public function close(success: Bool = true): Void { + this.hasExited = true; this.dispose(); - this.closeFutureResolev(success); + + EndOfLoop.endOfLoop(() ->{this.closeFutureResolev(success);}); ProcessManager.removeProcess(this.pid); } public function write(message: String): Void { + if (this.hasExited) return; if (this.config.onWrite != null){ this.config.onWrite.invoke(message); } @@ -77,6 +82,10 @@ class ProcessHandle { for (link in this.cbLinks) { link.cancel(); } + + for (func in this.deferFuncs) { + func(); + } } public function getPid(): PID { @@ -87,6 +96,10 @@ class ProcessHandle { this.cbLinks.push(link); } + public function addDeferFunc(func: Void -> Void) { + this.deferFuncs.push(func); + } + function get_args():ReadOnlyArray { return this.config.args; }