@Override @SuppressWarnings("unchecked") public T[] getValues(T[] array) { TimedNode<Object> h = getHead(); int s = size(h); if (s == 0) { if (array.length != 0) { array[0] = null; } } else { if (array.length < s) { array = (T[])Array.newInstance(array.getClass().getComponentType(), s); } int i = 0; while (i != s) { TimedNode<Object> next = h.get(); array[i] = (T)next.value; i++; h = next; } if (array.length > s) { array[s] = null; } } return array; }
index = getHead();
@NonNull public static <T> ReplaySubject<T> createWithTime(long maxAge, TimeUnit unit, Scheduler scheduler) { return new ReplaySubject<T>(new SizeAndTimeBoundReplayBuffer<T>(Integer.MAX_VALUE, maxAge, unit, scheduler));
@NonNull public static <T> ReplaySubject<T> createWithTimeAndSize(long maxAge, TimeUnit unit, Scheduler scheduler, int maxSize) { return new ReplaySubject<T>(new SizeAndTimeBoundReplayBuffer<T>(maxSize, maxAge, unit, scheduler));
index = getHead();
@NonNull public static <T> ReplaySubject<T> createWithTime(long maxAge, TimeUnit unit, Scheduler scheduler) { return new ReplaySubject<T>(new SizeAndTimeBoundReplayBuffer<T>(Integer.MAX_VALUE, maxAge, unit, scheduler));
@NonNull public static <T> ReplaySubject<T> createWithTimeAndSize(long maxAge, TimeUnit unit, Scheduler scheduler, int maxSize) { return new ReplaySubject<T>(new SizeAndTimeBoundReplayBuffer<T>(maxSize, maxAge, unit, scheduler));
@Override public void add(T value) { TimedNode<Object> n = new TimedNode<Object>(value, scheduler.now(unit)); TimedNode<Object> t = tail; tail = n; size++; t.set(n); // releases both the tail and size trim(); }
@Override public void addFinal(Object notificationLite) { TimedNode<Object> n = new TimedNode<Object>(notificationLite, Long.MAX_VALUE); TimedNode<Object> t = tail; tail = n; size++; t.lazySet(n); // releases both the tail and size trimFinal(); done = true; }
@Override @SuppressWarnings("unchecked") public T[] getValues(T[] array) { TimedNode<Object> h = getHead(); int s = size(h); if (s == 0) { if (array.length != 0) { array[0] = null; } } else { if (array.length < s) { array = (T[])Array.newInstance(array.getClass().getComponentType(), s); } int i = 0; while (i != s) { TimedNode<Object> next = h.get(); array[i] = (T)next.value; i++; h = next; } if (array.length > s) { array[s] = null; } } return array; }
@Override public void addFinal(Object notificationLite) { TimedNode<Object> n = new TimedNode<Object>(notificationLite, Long.MAX_VALUE); TimedNode<Object> t = tail; tail = n; size++; t.lazySet(n); // releases both the tail and size trimFinal(); done = true; }
@Override public void add(T value) { TimedNode<Object> n = new TimedNode<Object>(value, scheduler.now(unit)); TimedNode<Object> t = tail; tail = n; size++; t.set(n); // releases both the tail and size trim(); }