Sha256: 8a21116b695fc68b7144ca38dcf6eb88c20497c7e3414c6851041be7f165845e

Contents?: true

Size: 716 Bytes

Versions: 7

Compression:

Stored size: 716 Bytes

Contents

require 'thread'
class Thread
  undef :name if method_defined? :name
  undef :name= if method_defined? :name=

  # Returns the name of the current thread
  # Default:
  #    JRuby: The underlying Java thread name
  #    Other: String representation of this thread's object_id
  if defined? JRuby
    def name
      @name ||= JRuby.reference(self).native_thread.name
    end
  else
    def name
      @name ||= object_id.to_s
    end
  end

  # Set the name of this thread
  #   On JRuby it also sets the underlying Java Thread name
  if defined? JRuby
    def name=(name)
      JRuby.reference(self).native_thread.name = @name = name.to_s
    end
  else
    def name=(name)
      @name = name.to_s
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
semantic_logger-4.2.0 lib/semantic_logger/core_ext/thread.rb
semantic_logger-4.1.1 lib/semantic_logger/core_ext/thread.rb
semantic_logger-4.1.0 lib/semantic_logger/core_ext/thread.rb
semantic_logger-4.0.0 lib/semantic_logger/core_ext/thread.rb
semantic_logger-4.0.0.rc1 lib/semantic_logger/core_ext/thread.rb
semantic_logger-4.0.0.beta2 lib/semantic_logger/core_ext/thread.rb
semantic_logger-4.0.0.beta1 lib/semantic_logger/core_ext/thread.rb