class WeakConcurrentBag[A] extends AnyRef
A WeakConcurrentBag stores a collection of values, each wrapped in a
WeakReference
. The structure is optimized for addition, and will achieve
zero allocations in the happy path (aside from the allocation of the
WeakReference
, which is unavoidable). To remove a value from the bag, it is
sufficient to clear the corresponding weak reference, at which point the weak
reference will be removed from the bag during the next garbage collection.
Garbage collection happens regularly during the add
operation. Assuming
uniform distribution of hash codes of values added to the bag, the chance of
garbage collection occurring during an add
operation is 1/n, where n
is
the capacity of the table backing the bag.
- Alphabetic
- By Inheritance
- WeakConcurrentBag
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
add(value: A): WeakReference[A]
Adds the specified value to the concurrent bag, returning a
WeakReference
that wraps the value. -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
gc(): Unit
Performs garbage collection, removing any empty weak references.
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
iterator: Iterator[A]
Returns a weakly consistent iterator over the bag.
Returns a weakly consistent iterator over the bag. This iterator will never throw exceptions even in the presence of concurrent modifications.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
size: Int
Returns the size of the bag.
Returns the size of the bag. Due to concurrent modification, this is only an estimate. Note this operation is O(n.max(m)), where n is the number of elements in the collection, and m is the table size.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
final
def
toString(): String
- Definition Classes
- WeakConcurrentBag → AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()