All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jgroups.Refcountable Maven / Gradle / Ivy

Go to download

This artifact provides a single jar that contains all classes required to use remote EJB and JMS, including all dependencies. It is intended for use by those not using maven, maven users should just import the EJB and JMS BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up with different versions on classes on the class path).

There is a newer version: 34.0.0.Final
Show newest version
package org.jgroups;

/**
 * Provides ref-counting for messages (https://issues.redhat.com/browse/JGRP-2417). The idea is that the payload of the
 * message is a shared resource (e.g. memory from a pool), accessed by different threads. Each thread increments the
 * refcount. When a thread is done, it decrements the refcount, and when the count is 0, the shared resource can be
 * freed (ie. returned to the pool).
 * @author Bela Ban
 * @since  5.1.0
 */
public interface Refcountable {
    /**
     * Increments the refcount
     * @return T the type (typically a message)
     */
    T incr();

    /**
     * Decrements the refcount. This should not become negative. When the refount is 0 for the first time,
     * the shared resource can be returned (in order to be reused).
     * @return T the type (typically a message)
     */
    T decr();

    /**
     * Callback. Called when the refcount becomes 0 for the first time. This can be used for example to return the
     * payload of the message to a memory pool
     */
    // default void release() {}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy