1 // Copyright (c) Microsoft. All rights reserved.
2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4 namespace DotNetty.Common
5 {
6 /// <summary>
7 /// 引用计数的可复用对象的接口
8 /// </summary>
9 public interface IReferenceCounted
10 {
11 /// <summary>
12 /// 返回此对象的引用计数
13 /// </summary>
14 int ReferenceCount { get; }
15
16 /// <summary>
17 /// 保留 引用计数 +1
18 /// </summary>
19 IReferenceCounted Retain();
20
21 /// <summary>
22 /// 增加引用计数 <see cref="increment" />.
23 /// </summary>
24 IReferenceCounted Retain(int increment);
25
26 /// <summary>
27 /// 触摸 为调试目的,记录当前对象的访问位置。
28 /// 如果这个对象是确定被泄露,信息记录这一操作
29 /// </summary>
30 /// <returns></returns>
31 IReferenceCounted Touch();
32
33 /// <summary>
34 /// 记录该对象的当前访问的位置,用于调试目的额外的任意信息。
35 /// 如果该对象被确定为泄漏,此操作记录的信息将通过 资源泄漏检测器 <see cref="ResourceLeakDetector" /> 提供给您
36 ///
37 /// </summary>
38 IReferenceCounted Touch(object hint);
39
40 /// <summary>
41 /// 减少引用计数1和释放该对象的引用计数达到0时。
42 /// </summary>
43 /// <returns>true :当且仅当引用计数为0,此对象已经被释放</returns>
44 bool Release();
45
46 /// <summary>
47 /// 减少引用计数,释放该对象如果引用计数为0时 <see cref="decrement" />
48 /// </summary>
49 /// <returns>true 当且仅当引用计数为0,此对象已被释放</returns>
50 bool Release(int decrement);
51 }
52 }