Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
badrishc committed Sep 4, 2019
1 parent b2479ed commit d03bcea
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions cs/src/core/ClientSession/FASTERAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,27 +103,20 @@ internal async ValueTask CompleteCheckpointAsync(ClientSession<Key, Value, Input
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal async ValueTask InternalRefreshAsync(ClientSession<Key, Value, Input, Output, Context, Functions> clientSession)
{
clientSession.ResumeThread();

epoch.ProtectAndDrain();
epoch.Check();

// We check if we are in normal mode
var newPhaseInfo = SystemState.Copy(ref _systemState);
if (threadCtx.Value.phase == Phase.REST && newPhaseInfo.phase == Phase.REST && threadCtx.Value.version == newPhaseInfo.version)
if (clientSession.ctx.phase == Phase.REST && newPhaseInfo.phase == Phase.REST && clientSession.ctx.version == newPhaseInfo.version)
{
return;
}

// Moving to non-checkpointing phases
// In non-checkpointing phases
if (newPhaseInfo.phase == Phase.GC || newPhaseInfo.phase == Phase.PREPARE_GROW || newPhaseInfo.phase == Phase.IN_PROGRESS_GROW)
{
threadCtx.Value.phase = newPhaseInfo.phase;
return;
}

await HandleCheckpointingPhasesAsync(clientSession);
clientSession.SuspendThread();
}


Expand All @@ -143,6 +136,9 @@ private bool AtomicSwitch(FasterExecutionContext fromCtx, FasterExecutionContext

private async ValueTask HandleCheckpointingPhasesAsync(ClientSession<Key, Value, Input, Output, Context, Functions> clientSession, bool async = true)
{
if (async)
clientSession.ResumeThread();

var previousState = SystemState.Make(threadCtx.Value.phase, threadCtx.Value.version);
var finalState = SystemState.Copy(ref _systemState);

Expand Down Expand Up @@ -377,6 +373,9 @@ private async ValueTask HandleCheckpointingPhasesAsync(ClientSession<Key, Value,
previousState.word = currentState.word;
if (count++ == 10000) throw new Exception("HandleCheckpointingPhases do loop too long " + previousState + ":" + finalState);
} while (previousState.word != finalState.word);

if (async)
clientSession.SuspendThread();
}
}
}

0 comments on commit d03bcea

Please sign in to comment.