Module: Pantheios::Util::ThreadUtil
- Defined in:
- lib/pantheios/util/thread_util.rb
Overview
threading utilities
Defined Under Namespace
Modules: ThreadName
Class Method Summary collapse
-
.get_thread_name(t) ⇒ Object
Obtains the name of the calling thread.
-
.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
Obtains the name of the calling thread
27 28 29 30 31 32 33 34 |
# File 'lib/pantheios/util/thread_util.rb', line 27 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
17 18 19 20 21 22 23 24 |
# File 'lib/pantheios/util/thread_util.rb', line 17 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 |