Module: Moped::Threaded Private
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
This module contains logic for easy access to objects that have a lifecycle on the current thread.
Extracted from Mongoid’s Threaded
module.
Instance Method Summary collapse
-
#begin(name) ⇒ true
private
Begin entry into a named thread local stack.
-
#end(name) ⇒ true
private
Exit from a named thread local stack.
-
#executing?(name) ⇒ true
private
Are in the middle of executing the named stack.
-
#stack(name) ⇒ Array
private
Get the named stack.
Instance Method Details
#begin(name) ⇒ true
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Begin entry into a named thread local stack.
22 23 24 |
# File 'lib/moped/threaded.rb', line 22 def begin(name) stack(name).push(true) end |
#end(name) ⇒ true
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Exit from a named thread local stack.
50 51 52 |
# File 'lib/moped/threaded.rb', line 50 def end(name) stack(name).pop end |
#executing?(name) ⇒ true
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Are in the middle of executing the named stack
36 37 38 |
# File 'lib/moped/threaded.rb', line 36 def executing?(name) !stack(name).empty? end |
#stack(name) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get the named stack.
64 65 66 67 |
# File 'lib/moped/threaded.rb', line 64 def stack(name) stacks = (Thread.current[:__moped_threaded_stacks__] ||= {}) stacks[name] ||= [] end |