internal ValueTask <RmwAsyncResult <Input, Output, Context, Functions> > CompleteAsync(CancellationToken token = default) { Debug.Assert(_fasterKV.RelaxedCPR); AsyncIOContext <Key, Value> newDiskRequest = default; if (_diskRequest.asyncOperation != null && CompletionComputeStatus != Completed && Interlocked.CompareExchange(ref CompletionComputeStatus, Completed, Pending) == Pending) { try { if (_exception == default) { if (_clientSession.SupportAsync) { _clientSession.UnsafeResumeThread(); } try { var status = _fasterKV.InternalCompletePendingRequestFromContext(_clientSession.ctx, _clientSession.ctx, _clientSession.FasterSession, _diskRequest, ref _pendingContext, true, out newDiskRequest); _pendingContext.Dispose(); if (status != Status.PENDING) { return(new ValueTask <RmwAsyncResult <Input, Output, Context, Functions> >(new RmwAsyncResult <Input, Output, Context, Functions>(status, default))); } } finally { if (_clientSession.SupportAsync) { _clientSession.UnsafeSuspendThread(); } } } } catch (Exception e) { _exception = ExceptionDispatchInfo.Capture(e); } finally { _clientSession.ctx.ioPendingRequests.Remove(_pendingContext.id); _clientSession.ctx.asyncPendingCount--; _clientSession.ctx.pendingReads.Remove(); } } if (_exception != default) { _exception.Throw(); } return(SlowRmwAsync(_fasterKV, _clientSession, _pendingContext, newDiskRequest, token)); }
internal (Status, Output) Complete() { (Status, Output)_result = default; if (_diskRequest.asyncOperation != null && CompletionComputeStatus != Completed && Interlocked.CompareExchange(ref CompletionComputeStatus, Completed, Pending) == Pending) { try { if (_exception == default) { if (_clientSession.SupportAsync) { _clientSession.UnsafeResumeThread(); } try { Debug.Assert(_fasterKV.RelaxedCPR); var status = _fasterKV.InternalCompletePendingRequestFromContext(_clientSession.ctx, _clientSession.ctx, _clientSession.FasterSession, _diskRequest, ref _pendingContext, true, out _); Debug.Assert(status != Status.PENDING); _result = (status, _pendingContext.output); _pendingContext.Dispose(); } finally { if (_clientSession.SupportAsync) { _clientSession.UnsafeSuspendThread(); } } } } catch (Exception e) { _exception = ExceptionDispatchInfo.Capture(e); } finally { _clientSession.ctx.ioPendingRequests.Remove(_pendingContext.id); _clientSession.ctx.asyncPendingCount--; _clientSession.ctx.pendingReads.Remove(); } } if (_exception != default) { _exception.Throw(); } return(_result); }
/// <inheritdoc/> public Status DoFastOperation(FasterKV <Key, Value> fasterKV, ref PendingContext <Input, Output, Context> pendingContext, IFasterSession <Key, Value, Input, Output, Context> fasterSession, FasterExecutionContext <Input, Output, Context> currentCtx, bool asyncOp, out CompletionEvent flushEvent, out Output output) { output = default; flushEvent = fasterKV.hlog.FlushEvent; Status status = !this.diskRequest.IsDefault() ? fasterKV.InternalCompletePendingRequestFromContext(currentCtx, currentCtx, fasterSession, this.diskRequest, ref pendingContext, asyncOp, out AsyncIOContext <Key, Value> newDiskRequest) : fasterKV.CallInternalRMW(fasterSession, currentCtx, ref pendingContext, ref pendingContext.key.Get(), ref pendingContext.input.Get(), pendingContext.userContext, pendingContext.serialNum, asyncOp, out flushEvent, out newDiskRequest); if (status == Status.PENDING && !newDiskRequest.IsDefault()) { flushEvent = default; this.diskRequest = newDiskRequest; } return(status); }
internal (Status, Output) Complete() { (Status, Output)_result = default; if (_diskRequest.asyncOperation != null && CompletionComputeStatus != Completed && Interlocked.CompareExchange(ref CompletionComputeStatus, Completed, Pending) == Pending) { try { if (_exception == default) { _fasterSession.UnsafeResumeThread(); try { var status = _fasterKV.InternalCompletePendingRequestFromContext(_currentCtx, _currentCtx, _fasterSession, _diskRequest, ref _pendingContext, true, out _); Debug.Assert(!status.IsPending); _result = (status, _pendingContext.output); _recordMetadata = new(_pendingContext.recordInfo, _pendingContext.logicalAddress); _pendingContext.Dispose(); } finally { _fasterSession.UnsafeSuspendThread(); } } } catch (Exception e) { _exception = ExceptionDispatchInfo.Capture(e); } finally { _currentCtx.ioPendingRequests.Remove(_pendingContext.id); _currentCtx.asyncPendingCount--; _currentCtx.pendingReads.Remove(); } } if (_exception != default) { _exception.Throw(); } return(_result); }