Code formatting
This commit is contained in:
+12
-18
@@ -8,7 +8,7 @@ uses
|
||||
Myc.Signals;
|
||||
|
||||
type
|
||||
TMycState = class abstract( TInterfacedObject, IMycState )
|
||||
TMycState = class abstract(TInterfacedObject, IMycState)
|
||||
protected
|
||||
function GetIsSet: Boolean; virtual; abstract;
|
||||
public
|
||||
@@ -37,10 +37,11 @@ type
|
||||
strict private
|
||||
FSubscribers: TMycNotifyList<IMycSubscriber>; // List of subscribers waiting for this latch to be set.
|
||||
private
|
||||
[volatile] FCount: Integer; // The internal countdown value for the latch.
|
||||
[volatile]
|
||||
FCount: Integer; // The internal countdown value for the latch.
|
||||
function GetState: TState; // Implementation for IMycLatch.GetState and IMycFlag.GetState.
|
||||
protected
|
||||
function GetIsSet: Boolean; override; final; // Implementation for IMycState.GetIsSet.
|
||||
function GetIsSet: Boolean; override; final; // Implementation for IMycState.GetIsSet.
|
||||
public
|
||||
// Creates the latch with an initial count.
|
||||
// If ACount is 0 or less, the latch is effectively pre-set (delegates to FNull via CreateLatch factory).
|
||||
@@ -57,7 +58,7 @@ type
|
||||
function Notify: Boolean;
|
||||
end;
|
||||
|
||||
TMycNullLatch = class( TInterfacedObject, IMycLatch )
|
||||
TMycNullLatch = class(TInterfacedObject, IMycLatch)
|
||||
private
|
||||
function GetState: TState;
|
||||
function Notify: Boolean;
|
||||
@@ -70,10 +71,11 @@ type
|
||||
strict private
|
||||
FSubscribers: TMycNotifyList<IMycSubscriber>; // List of subscribers interested in state changes of this dirty flag.
|
||||
private
|
||||
[volatile] FFlag: Boolean; // Internal state: true if dirty/set, false if clean/reset.
|
||||
[volatile]
|
||||
FFlag: Boolean; // Internal state: true if dirty/set, false if clean/reset.
|
||||
function GetState: TState;
|
||||
protected
|
||||
function GetIsSet: Boolean; override; final; // Implementation for IMycState.GetIsSet (true if dirty).
|
||||
function GetIsSet: Boolean; override; final; // Implementation for IMycState.GetIsSet (true if dirty).
|
||||
public
|
||||
// Creates a new dirty flag, initially set to dirty (true).
|
||||
constructor Create;
|
||||
@@ -93,7 +95,7 @@ type
|
||||
function Reset: Boolean;
|
||||
end;
|
||||
|
||||
TMycNullDirty = class( TInterfacedObject, IMycDirty )
|
||||
TMycNullDirty = class(TInterfacedObject, IMycDirty)
|
||||
private
|
||||
function GetState: TState;
|
||||
function Notify: Boolean;
|
||||
@@ -150,7 +152,7 @@ end;
|
||||
constructor TMycLatch.Create(ACount: Integer);
|
||||
begin
|
||||
inherited Create;
|
||||
Assert( ACount >= 0 );
|
||||
Assert(ACount >= 0);
|
||||
FCount := ACount;
|
||||
FSubscribers.Create;
|
||||
end;
|
||||
@@ -177,11 +179,7 @@ begin
|
||||
|
||||
if shouldNotifySubscribers then
|
||||
begin
|
||||
FSubscribers.Notify(
|
||||
function(Subscriber: IMycSubscriber): Boolean
|
||||
begin
|
||||
Result := Subscriber.Notify;
|
||||
end);
|
||||
FSubscribers.Notify(function(Subscriber: IMycSubscriber): Boolean begin Result := Subscriber.Notify; end);
|
||||
end;
|
||||
|
||||
// Returns true if the latch has not yet been set by this Notify call (count > 0).
|
||||
@@ -315,11 +313,7 @@ begin
|
||||
|
||||
if wasPreviouslyClean then // Only notify subscribers if state changed from clean to dirty.
|
||||
begin
|
||||
FSubscribers.Notify(
|
||||
function(Subscriber: IMycSubscriber): Boolean
|
||||
begin
|
||||
Result := Subscriber.Notify;
|
||||
end);
|
||||
FSubscribers.Notify(function(Subscriber: IMycSubscriber): Boolean begin Result := Subscriber.Notify; end);
|
||||
end;
|
||||
// The return value of this Notify (as an IMycSubscriber) indicates if this
|
||||
// TMycDirty instance itself would want more notifications if it were subscribed to something.
|
||||
|
||||
Reference in New Issue
Block a user