Skip to content

Commit 36ea9b4

Browse files
committed
Isolate publisher confirmation code
Try to make `Channel` a bit more readable.
1 parent ecd948c commit 36ea9b4

File tree

2 files changed

+49
-8
lines changed

2 files changed

+49
-8
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// This source code is dual-licensed under the Apache License, version
2+
// 2.0, and the Mozilla Public License, version 2.0.
3+
//
4+
// The APL v2.0:
5+
//
6+
//---------------------------------------------------------------------------
7+
// Copyright (c) 2007-2024 Broadcom. All Rights Reserved.
8+
//
9+
// Licensed under the Apache License, Version 2.0 (the "License");
10+
// you may not use this file except in compliance with the License.
11+
// You may obtain a copy of the License at
12+
//
13+
// https://www.apache.org/licenses/LICENSE-2.0
14+
//
15+
// Unless required by applicable law or agreed to in writing, software
16+
// distributed under the License is distributed on an "AS IS" BASIS,
17+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
// See the License for the specific language governing permissions and
19+
// limitations under the License.
20+
//---------------------------------------------------------------------------
21+
//
22+
// The MPL v2.0:
23+
//
24+
//---------------------------------------------------------------------------
25+
// This Source Code Form is subject to the terms of the Mozilla Public
26+
// License, v. 2.0. If a copy of the MPL was not distributed with this
27+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
28+
//
29+
// Copyright (c) 2007-2024 Broadcom. All Rights Reserved.
30+
//---------------------------------------------------------------------------
31+
32+
using System.Collections.Concurrent;
33+
using System.Threading;
34+
using System.Threading.Tasks;
35+
36+
namespace RabbitMQ.Client.Impl
37+
{
38+
internal partial class Channel : IChannel, IRecoverable
39+
{
40+
// private readonly AsyncManualResetEvent _flowControlBlock = new AsyncManualResetEvent(true);
41+
42+
private bool _publisherConfirmationsEnabled = false;
43+
private bool _publisherConfirmationTrackingEnabled = false;
44+
private ulong _nextPublishSeqNo = 0;
45+
private readonly SemaphoreSlim _confirmSemaphore = new(1, 1);
46+
private readonly ConcurrentDictionary<ulong, TaskCompletionSource<bool>> _confirmsTaskCompletionSources = new();
47+
}
48+
}

projects/RabbitMQ.Client/Impl/Channel.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
using System;
3333
using System.Buffers.Binary;
34-
using System.Collections.Concurrent;
3534
using System.Collections.Generic;
3635
using System.Diagnostics;
3736
using System.Diagnostics.CodeAnalysis;
@@ -48,7 +47,7 @@
4847

4948
namespace RabbitMQ.Client.Impl
5049
{
51-
internal class Channel : IChannel, IRecoverable
50+
internal partial class Channel : IChannel, IRecoverable
5251
{
5352
///<summary>Only used to kick-start a connection open
5453
///sequence. See <see cref="Connection.OpenAsync"/> </summary>
@@ -60,12 +59,6 @@ internal class Channel : IChannel, IRecoverable
6059
private readonly RpcContinuationQueue _continuationQueue = new RpcContinuationQueue();
6160
private readonly AsyncManualResetEvent _flowControlBlock = new AsyncManualResetEvent(true);
6261

63-
private bool _publisherConfirmationsEnabled = false;
64-
private bool _publisherConfirmationTrackingEnabled = false;
65-
private ulong _nextPublishSeqNo = 0;
66-
private readonly SemaphoreSlim _confirmSemaphore = new(1, 1);
67-
private readonly ConcurrentDictionary<ulong, TaskCompletionSource<bool>> _confirmsTaskCompletionSources = new();
68-
6962
private ShutdownEventArgs? _closeReason;
7063
public ShutdownEventArgs? CloseReason => Volatile.Read(ref _closeReason);
7164

0 commit comments

Comments
 (0)