ReferenceQueue
open class ReferenceQueue<T : Any!>
| kotlin.Any | |
| ↳ | java.lang.ref.ReferenceQueue |
Reference queues, to which registered reference objects are appended by the garbage collector after the appropriate reachability changes are detected.
Summary
| Public constructors | |
|---|---|
|
Constructs a new reference-object queue. |
|
| Public methods | |
|---|---|
| open Reference<out T>! |
poll()Polls this queue to see if a reference object is available. |
| open Reference<out T>! |
remove()Removes the next reference object in this queue, blocking until one becomes available. |
| open Reference<out T>! |
Removes the next reference object in this queue, blocking until either one becomes available or the given timeout period expires. |
Public constructors
Public methods
poll
open fun poll(): Reference<out T>!
Polls this queue to see if a reference object is available. If one is available without further delay then it is removed from the queue and returned. Otherwise this method immediately returns null.
| Return | |
|---|---|
Reference<out T>! |
A reference object, if one was immediately available, otherwise null |
remove
open fun remove(): Reference<out T>!
Removes the next reference object in this queue, blocking until one becomes available.
| Return | |
|---|---|
Reference<out T>! |
A reference object, blocking until one becomes available |
| Exceptions | |
|---|---|
java.lang.InterruptedException |
If the wait is interrupted |
remove
open fun remove(timeout: Long): Reference<out T>!
Removes the next reference object in this queue, blocking until either one becomes available or the given timeout period expires.
This method does not offer real-time guarantees: It schedules the timeout as if by invoking the Object.wait(long) method.
| Parameters | |
|---|---|
timeout |
Long: If positive, block for up to timeout milliseconds while waiting for a reference to be added to this queue. If zero, block indefinitely. |
| Return | |
|---|---|
Reference<out T>! |
A reference object, if one was available within the specified timeout period, otherwise null |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
If the value of the timeout argument is negative |
java.lang.InterruptedException |
If the timeout wait is interrupted |