@Override public Runnable element() { return underlyingQueue.element(); }
public void testListeningDecorator_cancelled() throws Exception { ScheduledThreadPoolExecutor delegate = new ScheduledThreadPoolExecutor(1); BlockingQueue<?> delegateQueue = delegate.getQueue(); ListeningScheduledExecutorService service = listeningDecorator(delegate); ListenableFuture<?> future; ScheduledFuture<?> delegateFuture; Runnable runnable = new Runnable() { @Override public void run() {} }; future = service.schedule(runnable, 5, TimeUnit.MINUTES); future.cancel(true); assertTrue(future.isCancelled()); delegateFuture = (ScheduledFuture<?>) delegateQueue.element(); assertTrue(delegateFuture.isCancelled()); delegateQueue.clear(); future = service.scheduleAtFixedRate(runnable, 5, 5, TimeUnit.MINUTES); future.cancel(true); assertTrue(future.isCancelled()); delegateFuture = (ScheduledFuture<?>) delegateQueue.element(); assertTrue(delegateFuture.isCancelled()); delegateQueue.clear(); future = service.scheduleWithFixedDelay(runnable, 5, 5, TimeUnit.MINUTES); future.cancel(true); assertTrue(future.isCancelled()); delegateFuture = (ScheduledFuture<?>) delegateQueue.element(); assertTrue(delegateFuture.isCancelled()); }
void checkEmpty(BlockingQueue q) { try { assertTrue(q.isEmpty()); assertEquals(0, q.size()); assertNull(q.peek()); assertNull(q.poll()); assertNull(q.poll(0, MILLISECONDS)); assertEquals("[]", q.toString()); assertTrue(Arrays.equals(q.toArray(), new Object[0])); assertFalse(q.iterator().hasNext()); try { q.element(); shouldThrow(); } catch (NoSuchElementException success) { } try { q.iterator().next(); shouldThrow(); } catch (NoSuchElementException success) { } try { q.remove(); shouldThrow(); } catch (NoSuchElementException success) { } } catch (InterruptedException ie) { threadUnexpectedException(ie); } }
void checkEmpty(BlockingQueue q) { try { assertTrue(q.isEmpty()); assertEquals(0, q.size()); assertNull(q.peek()); assertNull(q.poll()); assertNull(q.poll(0, MILLISECONDS)); assertEquals(q.toString(), "[]"); assertTrue(Arrays.equals(q.toArray(), new Object[0])); assertFalse(q.iterator().hasNext()); try { q.element(); shouldThrow(); } catch (NoSuchElementException success) {} try { q.iterator().next(); shouldThrow(); } catch (NoSuchElementException success) {} try { q.remove(); shouldThrow(); } catch (NoSuchElementException success) {} } catch (InterruptedException fail) { threadUnexpectedException(fail); } }
void checkEmpty(BlockingQueue q) { try { assertTrue(q.isEmpty()); assertEquals(0, q.size()); assertNull(q.peek()); assertNull(q.poll()); assertNull(q.poll(randomExpiredTimeout(), randomTimeUnit())); assertEquals(q.toString(), "[]"); assertTrue(Arrays.equals(q.toArray(), new Object[0])); assertFalse(q.iterator().hasNext()); try { q.element(); shouldThrow(); } catch (NoSuchElementException success) {} try { q.iterator().next(); shouldThrow(); } catch (NoSuchElementException success) {} try { q.remove(); shouldThrow(); } catch (NoSuchElementException success) {} } catch (InterruptedException fail) { threadUnexpectedException(fail); } }
@Override public E element() { return queue.element(); }
@Override public Runnable element() { return underlyingQueue.element(); }
@Override public E element() { return localInternalQueue.element(); }
@Override public Runnable element() { return underlyingQueue.element(); }
@Override public ElementType element() { synchronized (this) { return this.queue.element(); } }
/** * Retrieves but does not remove the head of the queue. * @return the head of the queue * */ synchronized ResourceRequest head() { return requestQueue.element(); }
@Override public Runnable element() { return underlyingQueue.element(); }
@Override public T element() { return delegate.element(); }
@Override public MessageEvent element() { return queue.element(); }
public E element() { if (isRunning()) { return q.element(); } else { throw new NoSuchElementException(); } }
@Override public T element() { return setAuth(queue.element()); }
public E element() { synchronized (list) { Entry<E> entry = list.element(); if (entry == null) { return null; } return entry.getElement(); } }
public E element() { Lock l = lock.readLock(); l.lock(); try { return backing.element(); } finally { l.unlock(); } }
/** * Satisfies one resource for the front-most request. If that satisfies the * request, it is removed from the queue. */ final synchronized DriverRuntimeProtocol.ResourceRequestProto satisfyOne() { final ResourceRequest req = this.requestQueue.element(); req.satisfyOne(); if (req.isSatisfied()) { this.requestQueue.poll(); } return req.getRequestProto(); }
/** * Satisfies one resource for the front-most request. If that satisfies the * request, it is removed from the queue. */ synchronized ResourceRequestEvent satisfyOne() { final ResourceRequest req = this.requestQueue.element(); req.satisfyOne(); if (req.isSatisfied()) { this.requestQueue.poll(); } return req.getRequestProto(); }