trait TransferQueue[E] extends BlockingQueue[E]
A BlockingQueue
in which producers may wait for consumers
to receive elements. A TransferQueue
may be useful for
example in message passing applications in which producers
sometimes (using method #transfer
) await receipt of
elements by consumers invoking take
or poll
, while
at other times enqueue elements (via method put
) without
waiting for receipt.
Non-blocking and
time-out versions of
tryTransfer
are also available.
A TransferQueue
may also be queried, via #hasWaitingConsumer
, whether there are any threads waiting for
items, which is a converse analogy to a peek
operation.
Like other blocking queues, a TransferQueue
may be
capacity bounded. If so, an attempted transfer operation may
initially block waiting for available space, and/or subsequently
block waiting for reception by a consumer. Note that in a queue
with zero capacity, such as SynchronousQueue
, put
and transfer
are effectively synonymous.
This interface is a member of the Java Collections Framework.
- Source
- TransferQueue.java
- Since
1.7
- Alphabetic
- By Inheritance
- TransferQueue
- BlockingQueue
- Queue
- Collection
- Iterable
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
add(arg0: E): Boolean
- Definition Classes
- BlockingQueue → Queue → Collection
-
abstract
def
addAll(arg0: Collection[_ <: E]): Boolean
- Definition Classes
- Collection
-
abstract
def
clear(): Unit
- Definition Classes
- Collection
-
abstract
def
contains(arg0: Any): Boolean
- Definition Classes
- BlockingQueue → Collection
-
abstract
def
containsAll(arg0: Collection[_]): Boolean
- Definition Classes
- Collection
-
abstract
def
drainTo(arg0: Collection[_ >: E], arg1: Int): Int
- Definition Classes
- BlockingQueue
-
abstract
def
drainTo(arg0: Collection[_ >: E]): Int
- Definition Classes
- BlockingQueue
-
abstract
def
element(): E
- Definition Classes
- Queue
-
abstract
def
getWaitingConsumerCount(): Int
Returns an estimate of the number of consumers waiting to receive elements via
#take
or timedpoll
.Returns an estimate of the number of consumers waiting to receive elements via
#take
or timedpoll
. The return value is an approximation of a momentary state of affairs, that may be inaccurate if consumers have completed or given up waiting. The value may be useful for monitoring and heuristics, but not for synchronization control. Implementations of this method are likely to be noticeably slower than those for#hasWaitingConsumer
.- returns
the number of consumers waiting to receive elements
-
abstract
def
hasWaitingConsumer(): Boolean
Returns
true
if there is at least one consumer waiting to receive an element via#take
or timedpoll
.Returns
true
if there is at least one consumer waiting to receive an element via#take
or timedpoll
. The return value represents a momentary state of affairs.- returns
true
if there is at least one waiting consumer
-
abstract
def
isEmpty(): Boolean
- Definition Classes
- Collection
-
abstract
def
iterator(): Iterator[E]
- Definition Classes
- Collection → Iterable
-
abstract
def
offer(arg0: E, arg1: Long, arg2: TimeUnit): Boolean
- Definition Classes
- BlockingQueue
- Annotations
- @throws( ... )
-
abstract
def
offer(arg0: E): Boolean
- Definition Classes
- BlockingQueue → Queue
-
abstract
def
peek(): E
- Definition Classes
- Queue
-
abstract
def
poll(arg0: Long, arg1: TimeUnit): E
- Definition Classes
- BlockingQueue
- Annotations
- @throws( ... )
-
abstract
def
poll(): E
- Definition Classes
- Queue
-
abstract
def
put(arg0: E): Unit
- Definition Classes
- BlockingQueue
- Annotations
- @throws( ... )
-
abstract
def
remainingCapacity(): Int
- Definition Classes
- BlockingQueue
-
abstract
def
remove(arg0: Any): Boolean
- Definition Classes
- BlockingQueue → Collection
-
abstract
def
remove(): E
- Definition Classes
- Queue
-
abstract
def
removeAll(arg0: Collection[_]): Boolean
- Definition Classes
- Collection
-
abstract
def
retainAll(arg0: Collection[_]): Boolean
- Definition Classes
- Collection
-
abstract
def
size(): Int
- Definition Classes
- Collection
-
abstract
def
take(): E
- Definition Classes
- BlockingQueue
- Annotations
- @throws( ... )
-
abstract
def
toArray[T](arg0: Array[T]): Array[T]
- Definition Classes
- Collection
-
abstract
def
toArray(): Array[AnyRef]
- Definition Classes
- Collection
-
abstract
def
transfer(e: E): Unit
Transfers the element to a consumer, waiting if necessary to do so.
Transfers the element to a consumer, waiting if necessary to do so.
More precisely, transfers the specified element immediately if there exists a consumer already waiting to receive it (in
#take
or timedpoll
), else waits until the element is received by a consumer.- e
the element to transfer
- Exceptions thrown
ClassCastException
if the class of the specified element prevents it from being added to this queueIllegalArgumentException
if some property of the specified element prevents it from being added to this queueInterruptedException
if interrupted while waiting, in which case the element is not left enqueuedNullPointerException
if the specified element is null
-
abstract
def
tryTransfer(e: E, timeout: Long, unit: TimeUnit): Boolean
Transfers the element to a consumer if it is possible to do so before the timeout elapses.
Transfers the element to a consumer if it is possible to do so before the timeout elapses.
More precisely, transfers the specified element immediately if there exists a consumer already waiting to receive it (in
#take
or timedpoll
), else waits until the element is received by a consumer, returningfalse
if the specified wait time elapses before the element can be transferred.- e
the element to transfer
- timeout
how long to wait before giving up, in units of
unit
- unit
a
TimeUnit
determining how to interpret thetimeout
parameter- returns
true
if successful, orfalse
if the specified waiting time elapses before completion, in which case the element is not left enqueued
- Exceptions thrown
ClassCastException
if the class of the specified element prevents it from being added to this queueIllegalArgumentException
if some property of the specified element prevents it from being added to this queueInterruptedException
if interrupted while waiting, in which case the element is not left enqueuedNullPointerException
if the specified element is null
-
abstract
def
tryTransfer(e: E): Boolean
Transfers the element to a waiting consumer immediately, if possible.
Transfers the element to a waiting consumer immediately, if possible.
More precisely, transfers the specified element immediately if there exists a consumer already waiting to receive it (in
#take
or timedpoll
), otherwise returningfalse
without enqueuing the element.- e
the element to transfer
- returns
true
if the element was transferred, elsefalse
- Exceptions thrown
ClassCastException
if the class of the specified element prevents it from being added to this queueIllegalArgumentException
if some property of the specified element prevents it from being added to this queueNullPointerException
if the specified element is null
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
+(other: String): String
- Implicit
- This member is added by an implicit conversion from TransferQueue[E] to any2stringadd[TransferQueue[E]] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
-
def
->[B](y: B): (TransferQueue[E], B)
- Implicit
- This member is added by an implicit conversion from TransferQueue[E] to ArrowAssoc[TransferQueue[E]] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate() @throws( ... )
-
def
ensuring(cond: (TransferQueue[E]) ⇒ Boolean, msg: ⇒ Any): TransferQueue[E]
- Implicit
- This member is added by an implicit conversion from TransferQueue[E] to Ensuring[TransferQueue[E]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: (TransferQueue[E]) ⇒ Boolean): TransferQueue[E]
- Implicit
- This member is added by an implicit conversion from TransferQueue[E] to Ensuring[TransferQueue[E]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean, msg: ⇒ Any): TransferQueue[E]
- Implicit
- This member is added by an implicit conversion from TransferQueue[E] to Ensuring[TransferQueue[E]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean): TransferQueue[E]
- Implicit
- This member is added by an implicit conversion from TransferQueue[E] to Ensuring[TransferQueue[E]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
forEach(arg0: Consumer[_ >: E]): Unit
- Definition Classes
- Iterable
-
def
formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from TransferQueue[E] to StringFormat[TransferQueue[E]] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @inline()
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
parallelStream(): Stream[E]
- Definition Classes
- Collection
-
def
removeIf(arg0: Predicate[_ >: E]): Boolean
- Definition Classes
- Collection
-
def
spliterator(): Spliterator[E]
- Definition Classes
- Collection → Iterable
-
def
stream(): Stream[E]
- Definition Classes
- Collection
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toArray[T](arg0: IntFunction[Array[T]]): Array[T]
- Definition Classes
- Collection
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
→[B](y: B): (TransferQueue[E], B)
- Implicit
- This member is added by an implicit conversion from TransferQueue[E] to ArrowAssoc[TransferQueue[E]] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc