/** * Try to call {@link ReferenceCounted#retain(int)} if the specified message implements {@link ReferenceCounted}. * If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing. */ @SuppressWarnings("unchecked") public static <T> T retain(T msg, int increment) { if (msg instanceof ReferenceCounted) { return (T) ((ReferenceCounted) msg).retain(increment); } return msg; }
@Override ByteBuf retain0() { referenceCountDelegate.retain(); return this; }
@Override ByteBuf retain0(int increment) { referenceCountDelegate.retain(increment); return this; }
/** * Try to call {@link ReferenceCounted#retain()} if the specified message implements {@link ReferenceCounted}. * If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing. */ @SuppressWarnings("unchecked") public static <T> T retain(T msg) { if (msg instanceof ReferenceCounted) { return (T) ((ReferenceCounted) msg).retain(); } return msg; }
@Override ByteBuf retain0(int increment) { referenceCountDelegate.retain(increment); return this; }
@Override ByteBuf retain0() { referenceCountDelegate.retain(); return this; }
/** * Try to call {@link ReferenceCounted#retain()} if the specified message implements {@link ReferenceCounted}. * If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing. */ @SuppressWarnings("unchecked") public static <T> T retain(T msg) { if (msg instanceof ReferenceCounted) { return (T) ((ReferenceCounted) msg).retain(); } return msg; }
@Override ByteBuf retain0(int increment) { referenceCountDelegate.retain(increment); return this; }
@Override ByteBuf retain0() { referenceCountDelegate.retain(); return this; }
@Override ByteBuf retain0() { referenceCountDelegate.retain(); return this; }
@Override ByteBuf retain0(int increment) { referenceCountDelegate.retain(increment); return this; }
/** * Try to call {@link ReferenceCounted#retain(int)} if the specified message implements {@link ReferenceCounted}. * If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing. */ @SuppressWarnings("unchecked") public static <T> T retain(T msg, int increment) { if (msg instanceof ReferenceCounted) { return (T) ((ReferenceCounted) msg).retain(increment); } return msg; }
@Override ByteBuf retain0(int increment) { referenceCountDelegate.retain(increment); return this; }
@Override ByteBuf retain0() { referenceCountDelegate.retain(); return this; }
/** * Try to call {@link ReferenceCounted#retain()} if the specified message implements {@link ReferenceCounted}. * If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing. */ @SuppressWarnings("unchecked") public static <T> T retain(T msg) { if (msg instanceof ReferenceCounted) { return (T) ((ReferenceCounted) msg).retain(); } return msg; }
@Override ByteBuf retain0() { referenceCountDelegate.retain(); return this; }
/** * Try to call {@link ReferenceCounted#retain(int)} if the specified message implements {@link ReferenceCounted}. * If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing. */ @SuppressWarnings("unchecked") public static <T> T retain(T msg, int increment) { if (msg instanceof ReferenceCounted) { return (T) ((ReferenceCounted) msg).retain(increment); } return msg; }
@Override ByteBuf retain0(int increment) { referenceCountDelegate.retain(increment); return this; }
public Value get(Key key) { Value value = entries.get(key); if (value == null) { return null; } else { try { value.retain(); return value; } catch (Throwable t) { // Value was already destroyed between get() and retain() return null; } } }
/** * * @param first * the first key in the range * @param last * the last key in the range (inclusive) * @return a collections of the value found in cache */ public Collection<Value> getRange(Key first, Key last) { List<Value> values = Lists.newArrayList(); // Return the values of the entries found in cache for (Value value : entries.subMap(first, true, last, true).values()) { try { value.retain(); values.add(value); } catch (Throwable t) { // Value was already destroyed between get() and retain() } } return values; }