Data file handling

This commit is contained in:
Michael Schimmel
2025-06-15 17:29:56 +02:00
parent bbd9d1752a
commit 2c56f6e750
7 changed files with 578 additions and 357 deletions
+23 -7
View File
@@ -3,7 +3,8 @@ unit Myc.Signals;
interface
uses
System.SysUtils;
System.SysUtils,
System.SyncObjs;
type
TSignal = record
@@ -136,6 +137,8 @@ type
strict private
class var
FNull: ILatch;
FQueueGate: TLatch;
FQueueLock: TSpinLock;
class constructor ClassCreate;
private
@@ -150,7 +153,8 @@ type
class function CreateLatch(Count: Integer): TLatch; static;
class function Enqueue(var Gate: TLatch; Count: Integer = 1): TState; static;
class function Enqueue(var Gate: TLatch): TState; overload; static;
class function Enqueue: TState; overload; static;
class property Null: ILatch read FNull;
@@ -390,6 +394,7 @@ class constructor TLatch.ClassCreate;
begin
// Create a singleton null latch instance that is initially (and always) set.
FNull := TMycNullLatch.Create;
FQueueLock := TSpinLock.Create(false);
end;
constructor TLatch.Create(const ALatch: TLatch.ILatch);
@@ -407,12 +412,23 @@ begin
Result := FNull;
end;
class function TLatch.Enqueue(var Gate: TLatch; Count: Integer = 1): TState;
class function TLatch.Enqueue(var Gate: TLatch): TState;
begin
var gateState := Gate.State;
Gate := TMycLatch.Create(Count);
gateState.Subscribe(Gate);
exit(Gate.State);
var Latch: TLatch.ILatch := TMycLatch.Create(1);
FQueueLock.Enter;
try
Gate.State.Subscribe(Latch);
Gate := Latch;
Result := Latch.State;
finally
FQueueLock.Exit;
end;
end;
class function TLatch.Enqueue: TState;
begin
Result := Enqueue(FQueueGate);
end;
function TLatch.GetState: TState;