aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorSteven Harman <steven@harmanly.com>2014-04-06 22:06:18 -0400
committerSteven Harman <steven@harmanly.com>2014-04-06 22:06:18 -0400
commitcb12e0408a88ca128da9c7a8a46ff4c75b0c4dd9 (patch)
tree2777c148bfd0bf826bdade7983800c60446fda35 /activesupport
parent38ad5438cce26b23e24d268be3f9419627b76400 (diff)
downloadrails-cb12e0408a88ca128da9c7a8a46ff4c75b0c4dd9.tar.gz
rails-cb12e0408a88ca128da9c7a8a46ff4c75b0c4dd9.tar.bz2
rails-cb12e0408a88ca128da9c7a8a46ff4c75b0c4dd9.zip
Add documentation for Thread#freeze
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/thread.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/thread.rb b/activesupport/lib/active_support/core_ext/thread.rb
index ac1ffa4128..4cd6634558 100644
--- a/activesupport/lib/active_support/core_ext/thread.rb
+++ b/activesupport/lib/active_support/core_ext/thread.rb
@@ -62,6 +62,13 @@ class Thread
_locals.has_key?(key.to_sym)
end
+ # Freezes the thread so that thread local variables cannot be set via
+ # Thread#thread_variable_set, nor can fiber local variables be set.
+ #
+ # me = Thread.current
+ # me.freeze
+ # me.thread_variable_set(:oliver, "a") #=> RuntimeError: can't modify frozen thread locals
+ # me[:oliver] = "a" #=> RuntimeError: can't modify frozen thread locals
def freeze
_locals.freeze
super