From 0a9435991aea6fe8fc9d70e5f29660cbd34e69ec Mon Sep 17 00:00:00 2001 From: Cedric Pimenta Date: Mon, 28 May 2018 10:21:52 +0200 Subject: [PATCH] Make variables are thread-local instead of fiber-local --- lib/threadsafe_attr.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/threadsafe_attr.rb b/lib/threadsafe_attr.rb index fdd1429..462e786 100644 --- a/lib/threadsafe_attr.rb +++ b/lib/threadsafe_attr.rb @@ -9,13 +9,13 @@ def threadsafe_attr_accessor(*attrs) private def reader(attr) define_method(attr) do - Thread.current["#{self.name}.#{attr}"] + Thread.current.thread_variable_get("#{self.name}.#{attr}") end end def writer(attr) define_method("#{attr}=") do |value| - Thread.current["#{self.name}.#{attr}"] = value + Thread.current.thread_variable_set("#{self.name}.#{attr}", value) end end end