Skip to content

Commit

Permalink
dotnet format
Browse files Browse the repository at this point in the history
  • Loading branch information
mtmk committed Aug 11, 2024
1 parent a79d93e commit 2fa2542
Show file tree
Hide file tree
Showing 245 changed files with 26,878 additions and 4,679 deletions.
7 changes: 4 additions & 3 deletions src/NATS.Client/v1/AckType.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 The NATS Authors
// Copyright 2021 The NATS Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand Down Expand Up @@ -32,8 +32,9 @@ public AckType(string text, bool terminal)
Bytes = Encoding.ASCII.GetBytes(text);
IsTerminal = terminal;
}

public byte[] BodyBytes(long delayNanoseconds) {

public byte[] BodyBytes(long delayNanoseconds)
{
return delayNanoseconds < 1 ? Bytes : Encoding.ASCII.GetBytes($"{Text} {{\"delay\": {delayNanoseconds}}}");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/NATS.Client/v1/AsyncSubscription.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015-2018 The NATS Authors
// Copyright 2015-2018 The NATS Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand Down
56 changes: 50 additions & 6 deletions src/NATS.Client/v1/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public static SingleUseChannel<T> GetOrCreate()
public static void Return(SingleUseChannel<T> ch)
{
ch.reset();
if (Channels.Count < 1024) Channels.Add(ch);
if (Channels.Count < 1024)
Channels.Add(ch);
}

internal T get(int timeout)
Expand Down Expand Up @@ -93,15 +94,36 @@ internal void reset()
internal sealed class Channel<T>
{
readonly Queue<T> q;

/* Unmerged change from project 'NATS.Client(netstandard2.1)'
Before:
readonly Object qLock = new Object();
After:
readonly object qLock = new object();
*/

/* Unmerged change from project 'NATS.Client(net6.0)'
Before:
readonly Object qLock = new Object();
After:
readonly object qLock = new object();
*/

/* Unmerged change from project 'NATS.Client(net8.0)'
Before:
readonly Object qLock = new Object();
After:
readonly object qLock = new object();
*/
readonly object qLock = new object();

bool finished = false;

public string Name { get; set; }

internal Channel() : this(1024) {}
internal Channel() : this(1024) { }

internal Channel(string name) : this(1024, name) {}
internal Channel(string name) : this(1024, name) { }

internal Channel(int initialCapacity, string name = null)
{
Expand Down Expand Up @@ -168,9 +190,31 @@ internal T get(int timeout)
// Returns the number of items delivered into the buffer.
internal int get(int timeout, T[] buffer)
{
if (buffer.Length < 1) throw new ArgumentException();
if (buffer.Length < 1)
throw new ArgumentException();
/* Unmerged change from project 'NATS.Client(netstandard2.1)'
Before:
int delivered = 0;
After:
var delivered = 0;
*/

/* Unmerged change from project 'NATS.Client(net6.0)'
Before:
int delivered = 0;
After:
var delivered = 0;
*/

/* Unmerged change from project 'NATS.Client(net8.0)'
Before:
int delivered = 0;
After:
var delivered = 0;
*/


var delivered = 0;
var lockWasTaken = false;

try
Expand All @@ -184,7 +228,7 @@ internal int get(int timeout, T[] buffer)

if (q.Count > 0)
{
for (int ii = 0; ii < buffer.Length && q.Count > 0; ++ii)
for (var ii = 0; ii < buffer.Length && q.Count > 0; ++ii)
{
buffer[ii] = q.Dequeue();
delivered++;
Expand Down Expand Up @@ -219,7 +263,7 @@ internal int get(int timeout, T[] buffer)
// we can have an empty queue if there was a spurious wakeup.
if (q.Count > 0)
{
for (int ii = 0; ii < buffer.Length && q.Count > 0; ++ii)
for (var ii = 0; ii < buffer.Length && q.Count > 0; ++ii)
{
buffer[ii] = q.Dequeue();
delivered++;
Expand Down
Loading

0 comments on commit 2fa2542

Please sign in to comment.