Skip to content

Commit 7761400

Browse files
committed
FlowState property rename
1 parent d332cb7 commit 7761400

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

Core/Cleipnir.ResilientFunctions/CoreRuntime/FlowState.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class FlowState
1414
public StoredId Id { get; }
1515
public QueueManager QueueManager { get; }
1616
public int Threads { get; private set; }
17-
public int SuspendedThreads { get; private set; }
17+
public int WaitingThreads { get; private set; }
1818
public FlowTimeouts Timeouts { get; }
1919
public AsyncSignal InterruptSignal { get; } = new();
2020
public bool Suspended { get; private set; }
@@ -24,13 +24,13 @@ public FlowState(
2424
StoredId id,
2525
QueueManager queueManager,
2626
int threads,
27-
int suspendedThreads,
27+
int waitingThreads,
2828
FlowTimeouts timeouts)
2929
{
3030
Id = id;
3131
QueueManager = queueManager;
3232
Threads = threads;
33-
SuspendedThreads = suspendedThreads;
33+
WaitingThreads = waitingThreads;
3434
Timeouts = timeouts;
3535
SuspendedTask = _suspendedTcs.Task;
3636
}
@@ -50,7 +50,7 @@ public void ThreadCompleted()
5050
public void ThreadSuspended()
5151
{
5252
lock (_lock)
53-
SuspendedThreads++;
53+
WaitingThreads++;
5454
}
5555

5656
public bool ResumeThread()
@@ -59,7 +59,7 @@ public bool ResumeThread()
5959
if (Suspended)
6060
return false;
6161
else
62-
SuspendedThreads--;
62+
WaitingThreads--;
6363

6464
return true;
6565
}
@@ -71,7 +71,7 @@ public void Interrupt()
7171
if (Suspended)
7272
return;
7373

74-
SuspendedThreads = 0;
74+
WaitingThreads = 0;
7575
}
7676

7777
InterruptSignal.Fire();
@@ -80,8 +80,12 @@ public void Interrupt()
8080
public bool Suspend()
8181
{
8282
lock (_lock)
83-
return Threads == SuspendedThreads && (Suspended = true);
83+
if (Threads == WaitingThreads)
84+
Suspended = true;
85+
else
86+
return false;
87+
88+
_suspendedTcs.TrySetResult();
89+
return true;
8490
}
85-
86-
public void NotifySuspension() => _suspendedTcs.TrySetResult();
8791
}

Core/Cleipnir.ResilientFunctions/CoreRuntime/FlowsManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private async Task TimeoutCheckLoop()
4747
public FlowState AddFlow(StoredId id, QueueManager queueManager, FlowTimeouts timeouts)
4848
{
4949
lock (_lock)
50-
return _dict[id] = new FlowState(id, queueManager, threads: 1, suspendedThreads: 0, timeouts);
50+
return _dict[id] = new FlowState(id, queueManager, threads: 1, waitingThreads: 0, timeouts);
5151
}
5252

5353
public void RemoveFlow(StoredId id)

0 commit comments

Comments
 (0)