We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ae1dcc7 commit 0ccc44bCopy full SHA for 0ccc44b
lib/concurrent/tvar.rb
@@ -1,7 +1,13 @@
1
+require 'concurrent/threadlocalvar'
2
+
3
module Concurrent
4
5
ABORTED = Object.new
6
7
+ CURRENT_TRANSACTION = ThreadLocalVar.new(nil)
8
9
+ UndoLogEntry = Struct.new(:tvar, :value)
10
11
class TVar
12
13
def initialize(value)
@@ -30,8 +36,6 @@ def unsafe_value=(value)
30
36
31
37
end
32
38
33
- UndoLogEntry = Struct.new(:tvar, :value)
34
-
35
39
class Transaction
40
41
LOCK = Mutex.new
@@ -74,11 +78,11 @@ def unlock
74
78
75
79
76
80
def self.current
77
- Thread.current.thread_variable_get(:transaction)
81
+ CURRENT_TRANSACTION.value
82
83
84
def self.current=(transaction)
- Thread.current.thread_variable_set(:transaction, transaction)
85
+ CURRENT_TRANSACTION.value = transaction
86
87
88
0 commit comments