You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduce ReferenceCountUtil for safe and conditional release of ReferenceCounted objects.
Add missing author tags.
[#279][resolves#298]
Signed-off-by: Mark Paluch <[email protected]>
* 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 implied.
13
+
* See the License for the specific language governing permissions and
14
+
* limitations under the License.
15
+
*/
16
+
17
+
packageio.r2dbc.mssql.util;
18
+
19
+
importio.netty.util.ReferenceCounted;
20
+
importreactor.util.annotation.Nullable;
21
+
22
+
/**
23
+
* Collection of methods to handle objects that may implement {@link ReferenceCounted}.
24
+
*
25
+
* @author Mark Paluch
26
+
* @since 1.0.3
27
+
*/
28
+
publicclassReferenceCountUtil {
29
+
30
+
/**
31
+
* Try to call {@link ReferenceCounted#release()} if the specified object implements {@link ReferenceCounted} and its reference count is greater than zero.
32
+
* If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing.
if (objinstanceofReferenceCounted && ((ReferenceCounted) obj).refCnt() > 0) {
36
+
((ReferenceCounted) obj).release();
37
+
}
38
+
}
39
+
40
+
/**
41
+
* Try to call {@link ReferenceCounted#release()} if the specified object implements {@link ReferenceCounted} and its reference count is greater than zero.
42
+
* If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing.
0 commit comments