/** * Attempt to take a reference to the provided object; if it has already been released, null will be returned * @param t object to acquire a reference to * @return true iff success */ public boolean tryRef(T t) { Ref<T> ref = t.tryRef(); if (ref == null) return false; ref = references.put(t, ref); if (ref != null) ref.release(); // release dup return true; }
/** * Attempt to take a reference to the provided object; if it has already been released, null will be returned * @param t object to acquire a reference to * @return true iff success */ public boolean tryRef(T t) { Ref<T> ref = t.tryRef(); if (ref == null) return false; ref = references.put(t, ref); if (ref != null) ref.release(); // release dup return true; }
/** * Attempt to take a reference to the provided object; if it has already been released, null will be returned * @param t object to acquire a reference to * @return true iff success */ public boolean tryRef(T t) { Ref<T> ref = t.tryRef(); if (ref == null) return false; ref = references.put(t, ref); if (ref != null) ref.release(); // release dup return true; }
/** * Attempt to take a reference to the provided object; if it has already been released, null will be returned * @param t object to acquire a reference to * @return true iff success */ public boolean tryRef(T t) { Ref<T> ref = t.tryRef(); if (ref == null) return false; ref = references.put(t, ref); if (ref != null) ref.release(); // release dup return true; }
/** * Attempt to take a reference to the provided object; if it has already been released, null will be returned * @param t object to acquire a reference to * @return true iff success */ public boolean tryRef(T t) { Ref<T> ref = t.tryRef(); if (ref == null) return false; ref = references.put(t, ref); if (ref != null) ref.release(); // release dup return true; }
/** * Acquire a reference to all of the provided objects, or none */ public static <T extends RefCounted<T>> Refs<T> tryRef(Iterable<T> reference) { HashMap<T, Ref<T>> refs = new HashMap<>(); for (T rc : reference) { Ref<T> ref = rc.tryRef(); if (ref == null) { release(refs.values()); return null; } refs.put(rc, ref); } return new Refs<T>(refs); }
/** * Acquire a reference to all of the provided objects, or none */ public static <T extends RefCounted<T>> Refs<T> tryRef(Iterable<T> reference) { HashMap<T, Ref<T>> refs = new HashMap<>(); for (T rc : reference) { Ref<T> ref = rc.tryRef(); if (ref == null) { release(refs.values()); return null; } refs.put(rc, ref); } return new Refs<T>(refs); }
/** * Acquire a reference to all of the provided objects, or none */ public static <T extends RefCounted<T>> Refs<T> tryRef(Iterable<T> reference) { HashMap<T, Ref<T>> refs = new HashMap<>(); for (T rc : reference) { Ref<T> ref = rc.tryRef(); if (ref == null) { release(refs.values()); return null; } refs.put(rc, ref); } return new Refs<T>(refs); }
/** * Acquire a reference to all of the provided objects, or none */ public static <T extends RefCounted<T>> Refs<T> tryRef(Iterable<T> reference) { HashMap<T, Ref<T>> refs = new HashMap<>(); for (T rc : reference) { Ref<T> ref = rc.tryRef(); if (ref == null) { release(refs.values()); return null; } refs.put(rc, ref); } return new Refs<T>(refs); }
/** * Acquire a reference to all of the provided objects, or none */ public static <T extends RefCounted<T>> Refs<T> tryRef(Iterable<T> reference) { HashMap<T, Ref<T>> refs = new HashMap<>(); for (T rc : reference) { Ref<T> ref = rc.tryRef(); if (ref == null) { release(refs.values()); return null; } refs.put(rc, ref); } return new Refs<T>(refs); }