Class: Thread

Inherits:
Object
  • Object
show all
Defined in:
lib/gtk2applib/core_hacks.rb

Overview

Thread is Ruby core. I'm just adding do.

Class Method Summary (collapse)

Class Method Details

+ (Object) thread(header = '', trailer = '', &block)

The Thread wrapped version of puts_bang! I often do

Thread.new do
  begin
    ... stuff ..
  rescue Exception
    puts 'header... blah, blah, blah.'
    puts $!
    puts $!.backtrace
    puts 'trailer... blah, blah, blah.'
  end
end

With the following below, I'll be able to say Thread.thread('header...','trailer'){ ...stuff... }

Parameters:

  • header (String) (defaults to: '')
  • trailer (String) (defaults to: '')


61
62
63
# File 'lib/gtk2applib/core_hacks.rb', line 61

def self.thread(header='', trailer='', &block)
  Thread.new { Exception.puts_bang!(header, trailer, &block) }
end