| | 1 | | /* |
| | 2 | | * Copyright 2018 Stanislav Muhametsin. All rights Reserved. |
| | 3 | | * |
| | 4 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | 5 | | * you may not use this file except in compliance with the License. |
| | 6 | | * You may obtain a copy of the License at |
| | 7 | | * |
| | 8 | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | 9 | | * |
| | 10 | | * Unless required by applicable law or agreed to in writing, software |
| | 11 | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | 12 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| | 13 | | * implied. |
| | 14 | | * |
| | 15 | | * See the License for the specific language governing permissions and |
| | 16 | | * limitations under the License. |
| | 17 | | */ |
| | 18 | | using CBAM.Abstractions.Implementation; |
| | 19 | | using Newtonsoft.Json.Linq; |
| | 20 | | using System; |
| | 21 | | using System.Collections.Generic; |
| | 22 | | using System.IO; |
| | 23 | | using System.Linq; |
| | 24 | | using System.Net; |
| | 25 | | using System.Text; |
| | 26 | | using System.Threading; |
| | 27 | | using System.Threading.Tasks; |
| | 28 | | using UtilPack; |
| | 29 | |
|
| | 30 | | namespace CBAM.NATS.Implementation |
| | 31 | | { |
| | 32 | |
|
| | 33 | | internal sealed class ClientProtocolPoolInfo : PooledConnectionFunctionality |
| | 34 | | { |
| | 35 | |
|
| | 36 | | private Object _cancellationToken; |
| | 37 | |
|
| 4 | 38 | | public ClientProtocolPoolInfo( ClientProtocol protocol ) |
| | 39 | | { |
| | 40 | | //this.Socket = ArgumentValidator.ValidateNotNull( nameof( socket ), socket ); |
| 4 | 41 | | this.Protocol = ArgumentValidator.ValidateNotNull( nameof( protocol ), protocol ); |
| 4 | 42 | | } |
| | 43 | |
|
| 8 | 44 | | public ClientProtocol Protocol { get; } |
| | 45 | |
|
| | 46 | | //public Socket Socket { get; } |
| | 47 | |
|
| | 48 | | public CancellationToken CurrentCancellationToken |
| | 49 | | { |
| 0 | 50 | | get => (CancellationToken) this._cancellationToken; |
| 8 | 51 | | set => Interlocked.Exchange( ref this._cancellationToken, value ); |
| | 52 | | } |
| | 53 | |
|
| 0 | 54 | | public Boolean CanBeReturnedToPool => this.Protocol.CanBeReturnedToPool; |
| | 55 | |
|
| | 56 | | public void ResetCancellationToken() |
| | 57 | | { |
| 8 | 58 | | this._cancellationToken = null; |
| 8 | 59 | | } |
| | 60 | | } |
| | 61 | |
|
| | 62 | | } |