improved Processhandle
This commit is contained in:
parent
9a9041bd98
commit
7aa5698486
@ -21,6 +21,8 @@ class ProcessHandle {
|
||||
private var closeFutureResolev: Bool -> Void;
|
||||
private final windowContexts: Array<WindowContext> = [];
|
||||
private final cbLinks:Array<CallbackLink> = [];
|
||||
private final deferFuncs:Array<Void -> 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<String> {
|
||||
return this.config.args;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user