Skip to content

Commit

Permalink
Updated TVar to support Ruby 1.9.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jdantonio committed Feb 25, 2014
1 parent b6667be commit 2b158b9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/concurrent/tvar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,19 @@ def unlock
end

def self.current
Thread.current.thread_variable_get(:transaction)
if Thread.current.respond_to?(:thread_variable_get)
Thread.current.thread_variable_get(:transaction)
else
Thread.current[:transaction]
end
end

def self.current=(transaction)
Thread.current.thread_variable_set(:transaction, transaction)
if Thread.current.respond_to?(:thread_variable_set)
Thread.current.thread_variable_set(:transaction, transaction)
else
Thread.current[:transaction] = transaction
end
end

end
Expand Down

0 comments on commit 2b158b9

Please sign in to comment.