SyncVar

@deprecated("Use `java.util.concurrent.LinkedBlockingQueue with capacity 1` instead.", since = "2.13.0") class SyncVar[A]

A class to provide safe concurrent access to a mutable cell.

A class to provide safe concurrent access to a mutable cell. All methods are synchronized.

Type Params
A

type of the contained value

Deprecated
[Since version 2.13.0]
class Object
trait Matchable
class Any

Value members

Concrete methods

def get: A

Wait for this SyncVar to become defined and then get the stored value without modifying it.

Wait for this SyncVar to become defined and then get the stored value without modifying it.

Returns

value that is held in this container

def get(timeout: Long): Option[A]

Wait at least timeout milliseconds (possibly more) for this SyncVar to become defined and then get its value.

Wait at least timeout milliseconds (possibly more) for this SyncVar to become defined and then get its value.

Value Params
timeout

time in milliseconds to wait

Returns

None if variable is undefined after timeout, Some(value) otherwise

Check whether a value is stored in the synchronized variable.

Check whether a value is stored in the synchronized variable.

def put(x: A): Unit

Place a value in the SyncVar.

Place a value in the SyncVar. If the SyncVar already has a stored value, wait until another thread takes it.

def take(): A

Wait for this SyncVar to become defined and then get the stored value, unsetting it as a side effect.

Wait for this SyncVar to become defined and then get the stored value, unsetting it as a side effect.

Returns

value that was held in this container

def take(timeout: Long): A

Wait at least timeout milliseconds (possibly more) for this SyncVar to become defined and then get the stored value, unsetting it as a side effect.

Wait at least timeout milliseconds (possibly more) for this SyncVar to become defined and then get the stored value, unsetting it as a side effect.

Value Params
timeout

the amount of milliseconds to wait

Returns

the value or a throws an exception if the timeout occurs

Throws
NoSuchElementException

on timeout