/// <inheritdoc />
        public async ValueTask OnThreadState <Key, Value, Input, Output, Context, FasterSession>(
            SystemState current,
            SystemState prev,
            FasterKV <Key, Value> faster,
            FasterKV <Key, Value> .FasterExecutionContext <Input, Output, Context> ctx,
            FasterSession fasterSession,
            bool async = true,
            CancellationToken token = default) where Key : new()
            where Value : new()
            where FasterSession : IFasterSession
        {
            if (current.phase != Phase.WAIT_INDEX_CHECKPOINT)
            {
                return;
            }

            if (async && !faster.IsIndexFuzzyCheckpointCompleted())
            {
                fasterSession?.UnsafeSuspendThread();
                await faster.IsIndexFuzzyCheckpointCompletedAsync(token);

                fasterSession?.UnsafeResumeThread();
            }

            faster.GlobalStateMachineStep(current);
        }
        /// <inheritdoc />
        public async ValueTask OnThreadState <Key, Value, Input, Output, Context, FasterSession>(
            SystemState current,
            SystemState prev,
            FasterKV <Key, Value> faster,
            FasterKV <Key, Value> .FasterExecutionContext <Input, Output, Context> ctx,
            FasterSession fasterSession,
            bool async = true,
            CancellationToken token = default)
            where Key : new()
            where Value : new()
            where FasterSession : IFasterSession
        {
            switch (current.phase)
            {
            case Phase.PREP_INDEX_CHECKPOINT:
                if (ctx != null)
                {
                    if (!ctx.markers[EpochPhaseIdx.PrepareForIndexCheckpt])
                    {
                        ctx.markers[EpochPhaseIdx.PrepareForIndexCheckpt] = true;
                    }
                    faster.epoch.Mark(EpochPhaseIdx.PrepareForIndexCheckpt, current.version);
                }

                if (faster.epoch.CheckIsComplete(EpochPhaseIdx.PrepareForIndexCheckpt, current.version))
                {
                    faster.GlobalStateMachineStep(current);
                }
                break;

            case Phase.INDEX_CHECKPOINT:
                if (ctx != null)
                {
                    // Resetting the marker for a potential FULL or INDEX_ONLY checkpoint in the future
                    ctx.markers[EpochPhaseIdx.PrepareForIndexCheckpt] = false;
                }

                if (async && !faster.IsIndexFuzzyCheckpointCompleted())
                {
                    fasterSession?.UnsafeSuspendThread();
                    await faster.IsIndexFuzzyCheckpointCompletedAsync(token);

                    fasterSession?.UnsafeResumeThread();
                }

                faster.GlobalStateMachineStep(current);
                break;
            }
        }
Exemple #3
0
        /// <inheritdoc />
        public void OnThreadState <Key, Value, Input, Output, Context, FasterSession>(
            SystemState current,
            SystemState prev,
            FasterKV <Key, Value> faster,
            FasterKV <Key, Value> .FasterExecutionContext <Input, Output, Context> ctx,
            FasterSession fasterSession,
            List <ValueTask> valueTasks,
            CancellationToken token = default)
            where Key : new()
            where Value : new()
            where FasterSession : IFasterSession
        {
            switch (current.phase)
            {
            case Phase.PREP_INDEX_CHECKPOINT:
                faster.GlobalStateMachineStep(current);
                break;

            case Phase.WAIT_INDEX_CHECKPOINT:
                var notify = faster.IsIndexFuzzyCheckpointCompleted();
                notify = notify || !faster.SameCycle(current);

                if (valueTasks != null && !notify)
                {
                    var t = faster.IsIndexFuzzyCheckpointCompletedAsync(token);
                    if (!faster.SameCycle(current))
                    {
                        notify = true;
                    }
                    else
                    {
                        valueTasks.Add(t);
                    }
                }

                if (!notify)
                {
                    return;
                }
                faster.GlobalStateMachineStep(current);
                break;
            }
        }