Module: Pantheios::Util::ThreadUtil
- Defined in:
- lib/pantheios/util/thread_util.rb
Defined Under Namespace
Modules: ThreadName
Class Method Summary collapse
- .get_thread_name(t) ⇒ Object
-
.set_thread_name(t, name) ⇒ Object
Creates (if necessary) and sets the given thread’s
thread_name
attribute to the given name.
Class Method Details
.get_thread_name(t) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/pantheios/util/thread_util.rb', line 25 def self.get_thread_name t t ||= Thread.current return t.thread_name if t.respond_to? :thread_name t.to_s end |
.set_thread_name(t, name) ⇒ Object
Creates (if necessary) and sets the given thread’s thread_name
attribute to the given name
Signature
-
Parameters:
-
t
[Thread, nil] The thread to be named, ornil
if it should operate on the current (invoking) thread -
name
[String] The thread’s name
16 17 18 19 20 21 22 23 |
# File 'lib/pantheios/util/thread_util.rb', line 16 def self.set_thread_name t, name t ||= Thread.current class << t; attr_accessor :thread_name; end unless t.respond_to? :thread_name t.thread_name = name end |