Sha256: ac6d21bb4f7e9a22983d91ef3718b9888f996aef116be9914d709d759b97b5f0

Contents?: true

Size: 823 Bytes

Versions: 15

Compression:

Stored size: 823 Bytes

Contents

# -*- coding: binary -*-
module Rex

###
#
# This class provides a wrapper around Thread.new that can provide
# additional features if a corresponding thread provider is set.
#
###

class ThreadFactory

  @@provider = nil

  def self.provider=(val)
    @@provider = val
  end

  def self.spawn(name, crit, *args, &block)
    if @@provider
      if block
        return @@provider.spawn(name, crit, *args){ |*args_copy| block.call(*args_copy) }
      else
        return @@provider.spawn(name, crit, *args)
      end
    else
      t = nil
      if block
        t = ::Thread.new(*args){ |*args_copy| block.call(*args_copy) }
      else
        t = ::Thread.new(*args)
      end
      t[:tm_name] = name
      t[:tm_crit] = crit
      t[:tm_time] = Time.now
      t[:tm_call] = caller
      return t
    end

  end
end

end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
rex-2.0.13 lib/rex/thread_factory.rb
rex-2.0.12 lib/rex/thread_factory.rb
rex-2.0.11 lib/rex/thread_factory.rb
rex-2.0.10 lib/rex/thread_factory.rb
rex-2.0.9 lib/rex/thread_factory.rb
rex-2.0.8 lib/rex/thread_factory.rb
rex-2.0.7 lib/rex/thread_factory.rb
rex-2.0.5 lib/rex/thread_factory.rb
rex-2.0.4 lib/rex/thread_factory.rb
dstruct-0.0.1 lib/rex/thread_factory.rb
rex-2.0.3 lib/rex/thread_factory.rb
librex-0.0.999 lib/rex/thread_factory.rb
rex-2.0.2 lib/rex/thread_factory.rb
librex-0.0.71 lib/rex/thread_factory.rb
librex-0.0.70 lib/rex/thread_factory.rb