added windowContext to ProcessHandle

This commit is contained in:
2023-04-18 19:56:59 +02:00
parent 17be4149db
commit 2da337b8a9
3 changed files with 67 additions and 4 deletions

View File

@@ -2,10 +2,36 @@ package kernel.ps;
import kernel.ps.ProcessHandle.HandleConfig;
typedef PID = Int;
class ProcessManager {
public static function run(process:Process, config: HandleConfig):ProcessHandle {
var handle = new ProcessHandle(config);
private static final processList = new Map<PID,ProcessHandle>();
public static function run(process:Process, config: HandleConfig):PID {
var pid = createPID();
var handle = new ProcessHandle(config, pid);
processList.set(pid, handle);
process.run(handle);
return handle;
return pid;
}
private static function createPID(): PID {
// TODO: better PID generation
// generate a random PID
return Math.ceil(Math.random() * 1000000);
}
@:allow(kernel.ui.WindowManager)
private static function getProcess(pid:PID):Null<ProcessHandle>{
return processList.get(pid);
}
@:allow(kernel.ps.ProcessHandle)
private static function removeProcess(pid:PID):Void {
processList.remove(pid);
}
}