Home / File/ ReferenceCountUpdater.java — netty Source File

ReferenceCountUpdater.java — netty Source File

Architecture documentation for ReferenceCountUpdater.java, a java file in the netty codebase.

Entity Profile

Relationship Graph

Source Code

/*
 * Copyright 2019 The Netty Project
 *
 * The Netty Project licenses this file to you 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:
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package io.netty.util.internal;

import static io.netty.util.internal.ObjectUtil.checkPositive;

import io.netty.util.IllegalReferenceCountException;
import io.netty.util.ReferenceCounted;

/**
 * Common logic for {@link ReferenceCounted} implementations
 * @deprecated Instead of extending this class, prefer instead to include a {@link RefCnt} field and delegate to that.
 * This approach has better compatibility with Graal Native Image.
 */
@Deprecated
public abstract class ReferenceCountUpdater<T extends ReferenceCounted> {
    /*
     * Implementation notes:
     *
     * For the updated int field:
     *   Even => "real" refcount is (refCnt >>> 1)
     *   Odd  => "real" refcount is 0
     */

    protected ReferenceCountUpdater() {
    }

    protected abstract void safeInitializeRawRefCnt(T refCntObj, int value);

    protected abstract int getAndAddRawRefCnt(T refCntObj, int increment);

    protected abstract int getRawRefCnt(T refCnt);

    protected abstract int getAcquireRawRefCnt(T refCnt);

    protected abstract void setReleaseRawRefCnt(T refCnt, int value);

    protected abstract boolean casRawRefCnt(T refCnt, int expected, int value);

    public final int initialValue() {
        return 2;
    }

    public final void setInitialValue(T instance) {
        safeInitializeRawRefCnt(instance, initialValue());
    }

// ... (109 more lines)

Domain

Subdomains

Types

Frequently Asked Questions

What does ReferenceCountUpdater.java do?
ReferenceCountUpdater.java is a source file in the netty codebase, written in java. It belongs to the CommonUtil domain, Internal subdomain.
Where is ReferenceCountUpdater.java in the architecture?
ReferenceCountUpdater.java is located at common/src/main/java/io/netty/util/internal/ReferenceCountUpdater.java (domain: CommonUtil, subdomain: Internal, directory: common/src/main/java/io/netty/util/internal).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free