本文整理了Java中java.util.concurrent.BlockingQueue.element()
方法的一些代码示例,展示了BlockingQueue.element()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BlockingQueue.element()
方法的具体详情如下:
包路径:java.util.concurrent.BlockingQueue
类名称:BlockingQueue
方法名:element
暂无
代码示例来源:origin: apache/hbase
@Override
public Runnable element() {
return underlyingQueue.element();
}
代码示例来源:origin: google/guava
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());
}
代码示例来源:origin: google/guava
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);
}
}
代码示例来源:origin: ben-manes/caffeine
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); }
}
代码示例来源:origin: jankotek/mapdb
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); }
}
代码示例来源:origin: net.sf.jabb/jabb-core
@Override
public E element() {
return queue.element();
}
代码示例来源:origin: com.aliyun.hbase/alihbase-thrift
@Override
public Runnable element() {
return underlyingQueue.element();
}
代码示例来源:origin: smallnest/ZKRecipesByExample
@Override
public E element() {
return localInternalQueue.element();
}
代码示例来源:origin: co.cask.hbase/hbase
@Override
public Runnable element() {
return underlyingQueue.element();
}
代码示例来源:origin: rsb/rsb
@Override
public ElementType element() {
synchronized (this) {
return this.queue.element();
}
}
代码示例来源:origin: org.apache.reef/reef-runtime-local
/**
* Retrieves but does not remove the head of the queue.
* @return the head of the queue
*
*/
synchronized ResourceRequest head() {
return requestQueue.element();
}
代码示例来源:origin: org.apache.hbase/hbase-thrift
@Override
public Runnable element() {
return underlyingQueue.element();
}
代码示例来源:origin: com.mycila/mycila-pubsub
@Override
public T element() {
return delegate.element();
}
代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp
@Override
public MessageEvent element() {
return queue.element();
}
代码示例来源:origin: com.github.kaitoy.sneo/sneo-core
public E element() {
if (isRunning()) {
return q.element();
}
else {
throw new NoSuchElementException();
}
}
代码示例来源:origin: org.opendaylight.aaa/aaa-authn
@Override
public T element() {
return setAuth(queue.element());
}
代码示例来源:origin: org.eclipse.net4j/util
public E element()
{
synchronized (list)
{
Entry<E> entry = list.element();
if (entry == null)
{
return null;
}
return entry.getElement();
}
}
代码示例来源:origin: org.terracotta/product-upgradability-testing-utils
public E element() {
Lock l = lock.readLock();
l.lock();
try {
return backing.element();
} finally {
l.unlock();
}
}
代码示例来源:origin: com.microsoft.reef/reef-runtime-local
/**
* 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();
}
代码示例来源:origin: org.apache.reef/reef-runtime-local
/**
* 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();
}
内容来源于网络,如有侵权,请联系作者删除!