Module: Raptor::ThreadLocals
- Defined in:
- lib/raptor/thread_locals.rb,
sig/generated/raptor/thread_locals.rbs
Overview
Owns Raptor's reusable per-thread values and clears application thread locals after each request.
Constant Summary collapse
- PRESERVED_KEYS =
[ :raptor_http_parser, :raptor_read_buffer, :raptor_response_buffer ].freeze
Class Method Summary collapse
-
.clear ⇒ void
Clears application-owned true thread locals while retaining Raptor's reusable per-thread values.
-
.fetch(key) { ... } ⇒ Object
Returns a reusable value stored on the current thread.
Class Method Details
.clear ⇒ void
This method returns an undefined value.
Clears application-owned true thread locals while retaining Raptor's reusable per-thread values.
33 34 35 36 37 38 |
# File 'lib/raptor/thread_locals.rb', line 33 def self.clear thread = Thread.current thread.thread_variables.each do |key| thread.thread_variable_set(key, nil) unless PRESERVED_KEYS.include?(key) end end |
.fetch(key) { ... } ⇒ Object
Returns a reusable value stored on the current thread.
22 23 24 25 |
# File 'lib/raptor/thread_locals.rb', line 22 def self.fetch(key) thread = Thread.current thread.thread_variable_get(key) || thread.thread_variable_set(key, yield) end |