Sha256: e54ead4002a0f3831c80bcc342ab9a1117977878ddeeda2cfb332f052689850d

Contents?: true

Size: 635 Bytes

Versions: 3

Compression:

Stored size: 635 Bytes

Contents

require 'thread'
class Thread
  # Returns the name of the current thread
  # Default:
  #    JRuby: The Java thread name
  #    Other: String representation of this thread's object_id
  if defined? JRuby
    # Design Note:
    #   In JRuby with "thread.pool.enabled=true" each Ruby Thread instance is
    #   new, even though the Java threads are being re-used from the pool
    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 for logging and debugging purposes
  def name=(name)
    @name = name.to_s
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
semantic_logger-2.6.1 lib/semantic_logger/core_ext/thread.rb
semantic_logger-2.6.0 lib/semantic_logger/core_ext/thread.rb
semantic_logger-2.5.0 lib/semantic_logger/core_ext/thread.rb