Files
prometeu-runtime/crates/console/prometeu-system/src/services/process/model.rs
T
bquarkz be684ab0f9
Intrepid/Prometeu/Runtime/pipeline/head This commit looks good
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
add process and task managers
2026-05-14 17:39:55 +01:00

43 lines
1.0 KiB
Rust

use crate::process::{ProcessKind, ProcessState};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ProcessId(pub u32);
#[derive(Debug, Clone)]
pub struct Process {
pub id: ProcessId,
pub app_id: u32,
pub title: String,
pub kind: ProcessKind,
pub state: ProcessState,
}
impl Process {
pub fn new(id: ProcessId, app_id: u32, title: impl Into<String>, kind: ProcessKind) -> Self {
Self { id, app_id, title: title.into(), kind, state: ProcessState::Created }
}
pub fn mark_running(&mut self) {
self.state = ProcessState::Running;
}
pub fn mark_suspended(&mut self) {
self.state = ProcessState::Suspended;
}
pub fn mark_stopped(&mut self) {
self.state = ProcessState::Stopped;
}
pub fn mark_crashed(&mut self) {
self.state = ProcessState::Crashed;
}
pub fn is_alive(&self) -> bool {
matches!(
self.state,
ProcessState::Created | ProcessState::Running | ProcessState::Suspended
)
}
}