/// <summary>
        /// Complete outstanding pending operations that were issued synchronously
        /// Async operations (e.g., ReadAsync) need to be completed individually
        /// </summary>
        /// <returns></returns>
        internal async ValueTask CompletePendingAsync <Input, Output, Context>(IFasterSession <Key, Value, Input, Output, Context> fasterSession,
                                                                               FasterExecutionContext <Input, Output, Context> currentCtx, CancellationToken token,
                                                                               CompletedOutputIterator <Key, Value, Input, Output, Context> completedOutputs)
        {
            while (true)
            {
                fasterSession.UnsafeResumeThread();
                try
                {
                    InternalCompletePendingRequests(currentCtx, currentCtx, fasterSession, completedOutputs);
                    InternalCompleteRetryRequests(currentCtx, currentCtx, fasterSession);
                }
                finally
                {
                    fasterSession.UnsafeSuspendThread();
                }

                await currentCtx.WaitPendingAsync(token).ConfigureAwait(false);

                if (currentCtx.HasNoPendingRequests)
                {
                    return;
                }

                InternalRefresh(currentCtx, fasterSession);

                Thread.Yield();
            }
        }
Exemple #2
0
        /// <summary>
        /// Complete outstanding pending operations that were issued synchronously
        /// Async operations (e.g., ReadAsync) need to be completed individually
        /// </summary>
        /// <returns></returns>
        internal async ValueTask CompletePendingAsync <Input, Output, Context>(IFasterSession <Key, Value, Input, Output, Context> fasterSession,
                                                                               FasterExecutionContext <Input, Output, Context> currentCtx, CancellationToken token,
                                                                               CompletedOutputIterator <Key, Value, Input, Output, Context> completedOutputs)
        {
            while (true)
            {
                bool done = true;

                #region Previous pending requests
                if (!RelaxedCPR)
                {
                    if (currentCtx.phase == Phase.IN_PROGRESS || currentCtx.phase == Phase.WAIT_PENDING)
                    {
                        fasterSession.UnsafeResumeThread();
                        try
                        {
                            InternalCompletePendingRequests(currentCtx.prevCtx, currentCtx, fasterSession, completedOutputs);
                            InternalCompleteRetryRequests(currentCtx.prevCtx, currentCtx, fasterSession);
                        }
                        finally
                        {
                            fasterSession.UnsafeSuspendThread();
                        }
                        await currentCtx.prevCtx.WaitPendingAsync(token).ConfigureAwait(false);

                        done &= currentCtx.prevCtx.HasNoPendingRequests;
                    }
                }
                #endregion

                fasterSession.UnsafeResumeThread();
                try
                {
                    InternalCompletePendingRequests(currentCtx, currentCtx, fasterSession, completedOutputs);
                    InternalCompleteRetryRequests(currentCtx, currentCtx, fasterSession);
                }
                finally
                {
                    fasterSession.UnsafeSuspendThread();
                }

                await currentCtx.WaitPendingAsync(token).ConfigureAwait(false);

                done &= currentCtx.HasNoPendingRequests;

                if (done)
                {
                    return;
                }

                InternalRefresh(currentCtx, fasterSession);

                Thread.Yield();
            }
        }
Exemple #3
0
        internal bool InternalCompletePending <Input, Output, Context, FasterSession>(
            FasterExecutionContext <Input, Output, Context> ctx,
            FasterSession fasterSession,
            bool wait = false, CompletedOutputIterator <Key, Value, Input, Output, Context> completedOutputs = null)
            where FasterSession : IFasterSession <Key, Value, Input, Output, Context>
        {
            while (true)
            {
                bool done = true;

                #region Previous pending requests
                if (!RelaxedCPR)
                {
                    if (ctx.phase == Phase.IN_PROGRESS || ctx.phase == Phase.WAIT_PENDING)
                    {
                        InternalCompletePendingRequests(ctx.prevCtx, ctx, fasterSession, completedOutputs);
                        InternalCompleteRetryRequests(ctx.prevCtx, ctx, fasterSession);
                        if (wait)
                        {
                            ctx.prevCtx.WaitPending(epoch);
                        }
                        done &= ctx.prevCtx.HasNoPendingRequests;
                    }
                }
                #endregion

                InternalCompletePendingRequests(ctx, ctx, fasterSession, completedOutputs);
                InternalCompleteRetryRequests(ctx, ctx, fasterSession);
                if (wait)
                {
                    ctx.WaitPending(epoch);
                }
                done &= ctx.HasNoPendingRequests;

                if (done)
                {
                    return(true);
                }

                InternalRefresh(ctx, fasterSession);

                if (!wait)
                {
                    return(false);
                }
                Thread.Yield();
            }
        }
 public bool CompletePendingWithOutputs(out CompletedOutputIterator <Key, Value, Input, Output, Context> completedOutputs, bool wait = false, bool spinWaitForCommit = false)
 => throw new NotImplementedException();
 /// <inheritdoc/>
 public bool CompletePendingWithOutputs(out CompletedOutputIterator <Key, Value, Input, Output, Context> completedOutputs, bool wait = false, bool spinWaitForCommit = false)
 {
     Debug.Assert(clientSession.fht.epoch.ThisInstanceProtected());
     return(this.clientSession.UnsafeCompletePendingWithOutputs(this.FasterSession, out completedOutputs, wait, spinWaitForCommit));
 }
 public bool CompletePendingWithOutputs(out CompletedOutputIterator <Key, Value, Input, Output, Context> completedOutputs, bool wait = false, bool spinWaitForCommit = false)
 => _clientSession.CompletePendingWithOutputs(out completedOutputs, wait, spinWaitForCommit);