diff --git a/src/NATS.Client.Core/Commands/CommandWriter.cs b/src/NATS.Client.Core/Commands/CommandWriter.cs index 4b076922a..a44892ddc 100644 --- a/src/NATS.Client.Core/Commands/CommandWriter.cs +++ b/src/NATS.Client.Core/Commands/CommandWriter.cs @@ -242,6 +242,7 @@ public async ValueTask UnsubscribeAsync(int sid, int? maxMsgs, CancellationToken [MethodImpl(MethodImplOptions.NoInlining)] private static void ThrowOnDisconnected() => throw new NatsException("Connection hasn't been established yet."); + [MethodImpl(MethodImplOptions.AggressiveInlining)] private PipeWriter GetWriter() { lock (_lock) @@ -287,12 +288,14 @@ private async ValueTask PublishLockedAsync(string subject, string? replyTo, Nat } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private ValueTask UnLockAsync(CancellationToken cancellationToken) { Interlocked.Decrement(ref _counter.PendingMessages); return _channelLock.Reader.ReadAsync(cancellationToken); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private ValueTask LockAsync(CancellationToken cancellationToken) { Interlocked.Increment(ref _counter.PendingMessages);