From 44454e4f673e7c30f5781059206a2c6e869b7b90 Mon Sep 17 00:00:00 2001 From: mananni Date: Wed, 6 May 2026 10:18:00 -0400 Subject: [PATCH] Machine: add Uid property Expose a per-machine ulong Uid on IMachine/Machine, assigned from a static counter at machine construction time. --- src/Emulator/Main/Core/Machine.cs | 5 +++++ src/Emulator/Main/Peripherals/IMachine.cs | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/Emulator/Main/Core/Machine.cs b/src/Emulator/Main/Core/Machine.cs index 4a9de7d64..135381d5d 100644 --- a/src/Emulator/Main/Core/Machine.cs +++ b/src/Emulator/Main/Core/Machine.cs @@ -41,6 +41,7 @@ public class Machine : IMachine, IDisposable, IHasPreservableState { public Machine(bool createLocalTimeSource = false) { + machineUid = ++count; atomicState = new AtomicState(this); collectionSync = new object(); @@ -1305,6 +1306,8 @@ public RealTimeClockMode RealTimeClockMode } } + public ulong Uid => machineUid; + public Platform Platform { get; set; } public bool IsPaused @@ -1894,8 +1897,10 @@ private void InitializeInvalidatedAddressesList(ICPU cpu) private readonly MultiTree registeredPeripherals; private readonly object disposedSync; + private readonly ulong machineUid; private const int InitialDirtyListLength = 1 << 16; + private static ulong count = 0; private sealed class PausedState : IDisposable { diff --git a/src/Emulator/Main/Peripherals/IMachine.cs b/src/Emulator/Main/Peripherals/IMachine.cs index 855fa0276..a5327ce87 100644 --- a/src/Emulator/Main/Peripherals/IMachine.cs +++ b/src/Emulator/Main/Peripherals/IMachine.cs @@ -168,6 +168,8 @@ public interface IMachine : IEmulationElement Platform Platform { get; set; } + ulong Uid { get; } + bool IsPaused { get; } TimeStamp ElapsedVirtualTime { get; }