@Test public void testRemove() throws InterruptedException { for (int i = 1; i <= 10; i++) { Thread.sleep(10); wheel.add("test-" + i); } Assert.assertEquals(10, wheel.size()); wheel.remove("test-3"); wheel.remove("test-4"); wheel.remove("test-5"); Assert.assertEquals(7, wheel.size()); Set<String> set = wheel.elements(); Assert.assertEquals(7, set.size()); System.out.println(String.format("[CRAFT-ATOM-UTIL] (^_^) <%s> Case -> test timing wheel remove. ", CaseCounter.incr(3))); }
public boolean remove(E e) { synchronized (e) { Slot<E> slot = indicator.get(e); if (slot == null) { return false; } indicator.remove(e); return slot.remove(e) != null; } }
TimingWheel { public boolean remove(E e) { synchronized (e) { Slot<E> slot = indicator.get(e); if (slot == null) { return false; } indicator.remove(e); return slot.remove(e) != null; } } }
TimingWheel { public boolean remove(E e) { synchronized (e) { Slot<E> slot = indicator.get(e); if (slot == null) { return false; } indicator.remove(e); return slot.remove(e) != null; } } TimingWheel(int tickDuration, int ticksPerWheel, TimeUnit timeUnit); }
TimingWheel { public boolean remove(E e) { synchronized (e) { Slot<E> slot = indicator.get(e); if (slot == null) { return false; } indicator.remove(e); return slot.remove(e) != null; } } TimingWheel(int tickDuration, int ticksPerWheel, TimeUnit timeUnit); void start(); boolean stop(); void addExpirationListener(ExpirationListener<E> listener); void removeExpirationListener(ExpirationListener<E> listener); long add(E e); boolean remove(E e); int size(); Set<E> elements(); }
TimingWheel { public boolean remove(E e) { synchronized (e) { Slot<E> slot = indicator.get(e); if (slot == null) { return false; } indicator.remove(e); return slot.remove(e) != null; } } TimingWheel(int tickDuration, int ticksPerWheel, TimeUnit timeUnit); void start(); boolean stop(); void addExpirationListener(ExpirationListener<E> listener); void removeExpirationListener(ExpirationListener<E> listener); long add(E e); boolean remove(E e); int size(); Set<E> elements();  }