Package org.jgroups

Interface Refcountable<T>

  • All Known Implementing Classes:
    RefcountedBytesMessage, RefcountedNioMessage

    public interface Refcountable<T>
    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).
    Since:
    5.1.0
    • Method Detail

      • incr

        T incr()
        Increments the refcount
        Returns:
        T the type (typically a message)
      • decr

        T decr()
        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).
        Returns:
        T the type (typically a message)