/* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2024-2025 Gregory Lirent */ using System.Text.Json.Serialization; using WebmrAPI.Utils; namespace WebmrAPI.Models { public class ProcessThreadInfo : ConcurrentObject { private TimeSpan _lastPTime = TimeSpan.Zero; private TimeSpan _curPTime = TimeSpan.Zero; private int _id = 0; private int _currentPriority = 0; private int _basePriority = 0; private double _cpuUsage = 0; [JsonIgnore] public TimeSpan TotalProcessorTime { set { lock (_lock) { _lastPTime = _curPTime; _curPTime = value; } } } [JsonIgnore] public double ProcessorTime { get { lock (_lock) return (_curPTime - _lastPTime).TotalMilliseconds; } } public int ID { get => LockedGet(ref _id); set => LockedSet(ref _id, value); } public int CurrentPriority { get => LockedGet(ref _currentPriority); set => LockedSet(ref _currentPriority, value); } public int BasePriority { get => LockedGet(ref _basePriority); set => LockedSet(ref _basePriority, value); } public double CpuUsage { get => LockedGet(ref _cpuUsage); set => LockedSet(ref _cpuUsage, value); } } }