Class: Concurrent::ThreadLocalVar
- Inherits:
-
ThreadLocalVarImplementation
- Object
- Concurrent::ThreadLocalVar
- Defined in:
- lib/concurrent/atomic/thread_local_var.rb
Overview
A ‘ThreadLocalVar` is a variable where the value is different for each thread. Each variable may have a default value, but when you modify the variable only the current thread will ever see that change.
Testing with ruby 2.1.2 Testing with Concurrent::MutexAtomicBoolean…
2.790000 0.000000 2.790000 ( 2.791454)
Testing with Concurrent::CAtomicBoolean…
0.740000 0.000000 0.740000 ( 0.740206)
Testing with jruby 1.9.3 Testing with Concurrent::MutexAtomicBoolean…
5.240000 2.520000 7.760000 ( 3.683000)
Testing with Concurrent::JavaAtomicBoolean…
3.340000 0.010000 3.350000 ( 0.855000)
Instance Method Summary collapse
-
#bind(value) { ... } ⇒ Object
Bind the given value to thread local storage during execution of the given block.
-
#initialize(default = nil) ⇒ Object
constructor
Creates a thread local variable.
-
#value ⇒ Object
Returns the value in the current thread’s copy of this thread-local variable.
-
#value=(value) ⇒ Object
Sets the current thread’s copy of this thread-local variable to the specified value.
Constructor Details
#initialize(default = nil) ⇒ Object
Creates a thread local variable.
100 101 |
# File 'lib/concurrent/atomic/thread_local_var.rb', line 100 class ThreadLocalVar < ThreadLocalVarImplementation end |
Instance Method Details
#bind(value) { ... } ⇒ Object
Bind the given value to thread local storage during execution of the given block.
100 101 |
# File 'lib/concurrent/atomic/thread_local_var.rb', line 100 class ThreadLocalVar < ThreadLocalVarImplementation end |
#value ⇒ Object
Returns the value in the current thread’s copy of this thread-local variable.
100 101 |
# File 'lib/concurrent/atomic/thread_local_var.rb', line 100 class ThreadLocalVar < ThreadLocalVarImplementation end |
#value=(value) ⇒ Object
Sets the current thread’s copy of this thread-local variable to the specified value.
100 101 |
# File 'lib/concurrent/atomic/thread_local_var.rb', line 100 class ThreadLocalVar < ThreadLocalVarImplementation end |