ThreadLocal

cc.otavia.core.cache.ThreadLocal
See theThreadLocal companion object
abstract class ThreadLocal[V]

A special variant of ThreadLocal that yields higher access performance when accessed from a ActorThread.

Internally, a ThreadLocal uses a constant index in an array, instead of using hash code and hash table, to look for a variable. Although seemingly very subtle, it yields slight performance advantage over using a hash table, and it is useful when accessed frequently.

To take advantage of this thread-local variable, your thread must be a ActorThread. By default, all actors and channel are running by ActorThread.

Type parameters

V

the type of the thread-local variable

Attributes

See also

java.lang.ThreadLocal

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def get(): V

Returns the current value for the current thread

Returns the current value for the current thread

Attributes

def getIfExists: V | Null

Returns the current value for the current thread if it exists, null otherwise.

Returns the current value for the current thread if it exists, null otherwise.

Attributes

def isSet: Boolean

Returns true if and only if this thread-local variable is set.

Returns true if and only if this thread-local variable is set.

Attributes

def remove(): Unit

Sets the value to uninitialized for the specified thread local map. After this, any subsequent call to get() will trigger a new call to initialValue().

Sets the value to uninitialized for the specified thread local map. After this, any subsequent call to get() will trigger a new call to initialValue().

Attributes

def set(v: V): Unit

Set the value for the current thread.

Set the value for the current thread.

Attributes

Concrete methods

def cancelTimer(): Unit

Cancel the local variable timer task.

Cancel the local variable timer task.

Attributes

final def isInitial: Boolean

Returns true if the thread local variable has been initial, otherwise false.

Returns true if the thread local variable has been initial, otherwise false.

Attributes

Inherited methods

def handleTimeout(registerId: Long, resourceTimer: ResourceTimer): Unit

Handle TimeoutEvent for this TimeoutResource

Handle TimeoutEvent for this TimeoutResource

Value parameters

registerId

timer task register id in Timer.

resourceTimer

current time-out ResourceTimer

Attributes

Inherited from:
TimeoutResource (hidden)
protected def initialTimeoutTrigger: Option[TimeoutTrigger]

Initial TimeoutTrigger when initial a time-out resource like ThreadLocal

Initial TimeoutTrigger when initial a time-out resource like ThreadLocal

Attributes

Inherited from:
TimeoutResource (hidden)