-
Notifications
You must be signed in to change notification settings - Fork 569
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[C#] Do not auto-acquire lockable context (#740)
* Do not auto-acquire lockable context Expose Acquire/Release for LC FasterLogIterator dispose fix * Added BasicContext as struct wrapper for client session Convert LockableContext to struct * add getters for session contexts * updates * updates
- Loading branch information
Showing
7 changed files
with
351 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using System.Diagnostics; | ||
using System.Runtime.CompilerServices; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace FASTER.core | ||
{ | ||
/// <summary> | ||
/// Basic Faster Context implementation. | ||
/// </summary> | ||
public readonly struct BasicContext<Key, Value, Input, Output, Context, Functions> : IFasterContext<Key, Value, Input, Output, Context> | ||
where Functions : IFunctions<Key, Value, Input, Output, Context> | ||
{ | ||
readonly ClientSession<Key, Value, Input, Output, Context, Functions> clientSession; | ||
|
||
internal BasicContext(ClientSession<Key, Value, Input, Output, Context, Functions> clientSession) | ||
{ | ||
this.clientSession = clientSession; | ||
} | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public void UnsafeResumeThread() | ||
=> clientSession.UnsafeResumeThread(); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public void UnsafeResumeThread(out int resumeEpoch) | ||
=> clientSession.UnsafeResumeThread(out resumeEpoch); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public void UnsafeSuspendThread() | ||
=> clientSession.UnsafeSuspendThread(); | ||
|
||
#region IFasterContext | ||
|
||
/// <inheritdoc/> | ||
public bool CompletePending(bool wait = false, bool spinWaitForCommit = false) | ||
=> clientSession.CompletePending(wait, spinWaitForCommit); | ||
|
||
/// <inheritdoc/> | ||
public bool CompletePendingWithOutputs(out CompletedOutputIterator<Key, Value, Input, Output, Context> completedOutputs, bool wait = false, bool spinWaitForCommit = false) | ||
=> clientSession.CompletePendingWithOutputs(out completedOutputs, wait, spinWaitForCommit); | ||
|
||
/// <inheritdoc/> | ||
public ValueTask CompletePendingAsync(bool waitForCommit = false, CancellationToken token = default) | ||
=> clientSession.CompletePendingAsync(waitForCommit, token); | ||
|
||
/// <inheritdoc/> | ||
public ValueTask<CompletedOutputIterator<Key, Value, Input, Output, Context>> CompletePendingWithOutputsAsync(bool waitForCommit = false, CancellationToken token = default) | ||
=> clientSession.CompletePendingWithOutputsAsync(waitForCommit, token); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status Read(ref Key key, ref Input input, ref Output output, Context userContext = default, long serialNo = 0) | ||
=> clientSession.Read(ref key, ref input, ref output, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status Read(Key key, Input input, out Output output, Context userContext = default, long serialNo = 0) | ||
=> clientSession.Read(key, input, out output, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status Read(ref Key key, ref Output output, Context userContext = default, long serialNo = 0) | ||
=> clientSession.Read(ref key, ref output, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status Read(Key key, out Output output, Context userContext = default, long serialNo = 0) | ||
=> clientSession.Read(key, out output, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public (Status status, Output output) Read(Key key, Context userContext = default, long serialNo = 0) | ||
=> clientSession.Read(key, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status Read(ref Key key, ref Input input, ref Output output, ref ReadOptions readOptions, out RecordMetadata recordMetadata, Context userContext = default, long serialNo = 0) | ||
=> clientSession.Read(ref key, ref input, ref output, ref readOptions, out recordMetadata, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status ReadAtAddress(ref Input input, ref Output output, ref ReadOptions readOptions, Context userContext = default, long serialNo = 0) | ||
=> clientSession.ReadAtAddress(ref input, ref output, ref readOptions, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public ValueTask<FasterKV<Key, Value>.ReadAsyncResult<Input, Output, Context>> ReadAsync(ref Key key, ref Input input, Context userContext = default, long serialNo = 0, CancellationToken cancellationToken = default) | ||
=> clientSession.ReadAsync(ref key, ref input, userContext, serialNo, cancellationToken); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public ValueTask<FasterKV<Key, Value>.ReadAsyncResult<Input, Output, Context>> ReadAsync(Key key, Input input, Context context = default, long serialNo = 0, CancellationToken token = default) | ||
=> clientSession.ReadAsync(key, input, context, serialNo, token); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public ValueTask<FasterKV<Key, Value>.ReadAsyncResult<Input, Output, Context>> ReadAsync(ref Key key, Context userContext = default, long serialNo = 0, CancellationToken token = default) | ||
=> clientSession.ReadAsync(ref key, userContext, serialNo, token); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public ValueTask<FasterKV<Key, Value>.ReadAsyncResult<Input, Output, Context>> ReadAsync(Key key, Context context = default, long serialNo = 0, CancellationToken token = default) | ||
=> clientSession.ReadAsync(key, context, serialNo, token); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public ValueTask<FasterKV<Key, Value>.ReadAsyncResult<Input, Output, Context>> ReadAsync(ref Key key, ref Input input, ref ReadOptions readOptions, Context userContext = default, long serialNo = 0, CancellationToken cancellationToken = default) | ||
=> clientSession.ReadAsync(ref key, ref input, ref readOptions, userContext, serialNo, cancellationToken); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public ValueTask<FasterKV<Key, Value>.ReadAsyncResult<Input, Output, Context>> ReadAtAddressAsync(ref Input input, ref ReadOptions readOptions, Context userContext = default, long serialNo = 0, CancellationToken cancellationToken = default) | ||
=> clientSession.ReadAtAddressAsync(ref input, ref readOptions, userContext, serialNo, cancellationToken); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status Upsert(ref Key key, ref Value desiredValue, Context userContext = default, long serialNo = 0) | ||
=> clientSession.Upsert(ref key, ref desiredValue, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status Upsert(ref Key key, ref Input input, ref Value desiredValue, ref Output output, Context userContext = default, long serialNo = 0) | ||
=> clientSession.Upsert(ref key, ref input, ref desiredValue, ref output, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status Upsert(ref Key key, ref Input input, ref Value desiredValue, ref Output output, out RecordMetadata recordMetadata, Context userContext = default, long serialNo = 0) | ||
=> clientSession.Upsert(ref key, ref input, ref desiredValue, ref output, out recordMetadata, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status Upsert(Key key, Value desiredValue, Context userContext = default, long serialNo = 0) | ||
=> clientSession.Upsert(key, desiredValue, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status Upsert(Key key, Input input, Value desiredValue, ref Output output, Context userContext = default, long serialNo = 0) | ||
=> clientSession.Upsert(key, input, desiredValue, ref output, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public ValueTask<FasterKV<Key, Value>.UpsertAsyncResult<Input, Output, Context>> UpsertAsync(ref Key key, ref Value desiredValue, Context userContext = default, long serialNo = 0, CancellationToken token = default) | ||
=> clientSession.UpsertAsync(ref key, ref desiredValue, userContext, serialNo, token); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public ValueTask<FasterKV<Key, Value>.UpsertAsyncResult<Input, Output, Context>> UpsertAsync(ref Key key, ref Input input, ref Value desiredValue, Context userContext = default, long serialNo = 0, CancellationToken token = default) | ||
=> clientSession.UpsertAsync(ref key, ref input, ref desiredValue, userContext, serialNo, token); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public ValueTask<FasterKV<Key, Value>.UpsertAsyncResult<Input, Output, Context>> UpsertAsync(Key key, Value desiredValue, Context userContext = default, long serialNo = 0, CancellationToken token = default) | ||
=> clientSession.UpsertAsync(key, desiredValue, userContext, serialNo, token); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public ValueTask<FasterKV<Key, Value>.UpsertAsyncResult<Input, Output, Context>> UpsertAsync(Key key, Input input, Value desiredValue, Context userContext = default, long serialNo = 0, CancellationToken token = default) | ||
=> clientSession.UpsertAsync(key, input, desiredValue, userContext, serialNo, token); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status RMW(ref Key key, ref Input input, ref Output output, Context userContext = default, long serialNo = 0) | ||
=> clientSession.RMW(ref key, ref input, ref output, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status RMW(ref Key key, ref Input input, ref Output output, out RecordMetadata recordMetadata, Context userContext = default, long serialNo = 0) | ||
=> clientSession.RMW(ref key, ref input, ref output, out recordMetadata, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status RMW(Key key, Input input, out Output output, Context userContext = default, long serialNo = 0) | ||
=> clientSession.RMW(key, input, out output, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status RMW(ref Key key, ref Input input, Context userContext = default, long serialNo = 0) | ||
=> clientSession.RMW(ref key, ref input, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status RMW(Key key, Input input, Context userContext = default, long serialNo = 0) | ||
=> clientSession.RMW(key, input, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public ValueTask<FasterKV<Key, Value>.RmwAsyncResult<Input, Output, Context>> RMWAsync(ref Key key, ref Input input, Context context = default, long serialNo = 0, CancellationToken token = default) | ||
=> clientSession.RMWAsync(ref key, ref input, context, serialNo, token); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public ValueTask<FasterKV<Key, Value>.RmwAsyncResult<Input, Output, Context>> RMWAsync(Key key, Input input, Context context = default, long serialNo = 0, CancellationToken token = default) | ||
=> clientSession.RMWAsync(key, input, context, serialNo, token); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status Delete(ref Key key, Context userContext = default, long serialNo = 0) | ||
=> clientSession.Delete(ref key, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public Status Delete(Key key, Context userContext = default, long serialNo = 0) | ||
=> clientSession.Delete(key, userContext, serialNo); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public ValueTask<FasterKV<Key, Value>.DeleteAsyncResult<Input, Output, Context>> DeleteAsync(ref Key key, Context userContext = default, long serialNo = 0, CancellationToken token = default) | ||
=> clientSession.DeleteAsync(ref key, userContext, serialNo, token); | ||
|
||
/// <inheritdoc/> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public ValueTask<FasterKV<Key, Value>.DeleteAsyncResult<Input, Output, Context>> DeleteAsync(Key key, Context userContext = default, long serialNo = 0, CancellationToken token = default) | ||
=> clientSession.DeleteAsync(key, userContext, serialNo, token); | ||
|
||
/// <inheritdoc/> | ||
public void Refresh() | ||
=> clientSession.Refresh(); | ||
|
||
#endregion IFasterContext | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.