Example usage for io.netty.util IllegalReferenceCountException IllegalReferenceCountException

List of usage examples for io.netty.util IllegalReferenceCountException IllegalReferenceCountException

Introduction

In this page you can find the example usage for io.netty.util IllegalReferenceCountException IllegalReferenceCountException.

Prototype

public IllegalReferenceCountException(String message, Throwable cause) 

Source Link

Usage

From source file:net.tomp2p.storage.AlternativeCompositeByteBuf.java

License:Apache License

@Override
public boolean release() {
    for (;;) {/*from  ww  w  .  ja v a2s . c  o m*/
        int refCnt = this.refCnt;
        if (refCnt == 0) {
            throw new IllegalReferenceCountException(0, -1);
        }

        if (refCntUpdater.compareAndSet(this, refCnt, refCnt - 1)) {
            if (refCnt == 1) {
                deallocate();
                return true;
            }
            return false;
        }
    }
}

From source file:net.tomp2p.storage.AlternativeCompositeByteBuf.java

License:Apache License

@Override
public boolean release(int decrement) {
    if (decrement <= 0) {
        throw new IllegalArgumentException("decrement: " + decrement + " (expected: > 0)");
    }/*from   w  ww .j  av  a  2s.  c  o  m*/

    for (;;) {
        int refCnt = this.refCnt;
        if (refCnt < decrement) {
            throw new IllegalReferenceCountException(refCnt, -decrement);
        }

        if (refCntUpdater.compareAndSet(this, refCnt, refCnt - decrement)) {
            if (refCnt == decrement) {
                deallocate();
                return true;
            }
            return false;
        }
    }
}

From source file:net.tomp2p.storage.AlternativeCompositeByteBuf.java

License:Apache License

@Override
public AlternativeCompositeByteBuf retain(int increment) {
    if (increment <= 0) {
        throw new IllegalArgumentException("increment: " + increment + " (expected: > 0)");
    }/*  w w  w.j  av a2  s . c  o m*/

    for (;;) {
        int refCnt = this.refCnt;
        if (refCnt == 0) {
            throw new IllegalReferenceCountException(0, increment);
        }
        if (refCnt > Integer.MAX_VALUE - increment) {
            throw new IllegalReferenceCountException(refCnt, increment);
        }
        if (refCntUpdater.compareAndSet(this, refCnt, refCnt + increment)) {
            break;
        }
    }
    return this;
}

From source file:net.tomp2p.storage.AlternativeCompositeByteBuf.java

License:Apache License

@Override
public AlternativeCompositeByteBuf retain() {
    for (;;) {//from   w w  w  .  j  av a  2 s.  com
        int refCnt = this.refCnt;
        if (refCnt == 0) {
            throw new IllegalReferenceCountException(0, 1);
        }
        if (refCnt == Integer.MAX_VALUE) {
            throw new IllegalReferenceCountException(Integer.MAX_VALUE, 1);
        }
        if (refCntUpdater.compareAndSet(this, refCnt, refCnt + 1)) {
            break;
        }
    }
    return this;
}

From source file:org.apache.bookkeeper.mledger.util.AbstractCASReferenceCounted.java

License:Apache License

private ReferenceCounted retain0(int increment) {
    for (;;) {//w w  w . j a v  a 2  s. c  om
        int refCnt = this.refCnt;
        final int nextCnt = refCnt + increment;

        // Ensure we not resurrect (which means the refCnt was 0) and also that we encountered an overflow.
        if (nextCnt <= increment) {
            throw new IllegalReferenceCountException(refCnt, increment);
        }
        if (refCntUpdater.compareAndSet(this, refCnt, nextCnt)) {
            break;
        }
    }
    return this;
}

From source file:org.apache.bookkeeper.mledger.util.AbstractCASReferenceCounted.java

License:Apache License

private boolean release0(int decrement) {
    for (;;) {//from  www . j av  a  2  s.c om
        int refCnt = this.refCnt;
        if (refCnt < decrement) {
            throw new IllegalReferenceCountException(refCnt, -decrement);
        }

        if (refCntUpdater.compareAndSet(this, refCnt, refCnt - decrement)) {
            if (refCnt == decrement) {
                deallocate();
                return true;
            }
            return false;
        }
    }
}