Skip to content

Use ActiveSupport::IsolatedExecutionState to get and set thread or fiber variables depending on the environment #6004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/mongoid/threaded.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module Threaded
# @return [ Object | nil ] the value of the queried variable, or nil if
# it is not set and no default was given.
def get(key, &default)
result = Thread.current.thread_variable_get(key)
result = ActiveSupport::IsolatedExecutionState[key]

if result.nil? && default
result = yield
Expand All @@ -75,7 +75,7 @@ def get(key, &default)
# @param [ Object | nil ] value the value of the variable to set (or `nil`
# if you wish to unset the variable)
def set(key, value)
Thread.current.thread_variable_set(key, value)
ActiveSupport::IsolatedExecutionState[key] = value
end

# Removes the named variable from thread-local storage.
Expand Down