Sha256: 144603d0b4ef12f88055dc2abe6884548cc6a87bd14b90fc6bc49c4a3174b2a3

Contents?: true

Size: 737 Bytes

Versions: 39

Compression:

Stored size: 737 Bytes

Contents

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

39 entries across 39 versions & 1 rubygems

Version Path
librex-0.0.65 lib/rex/thread_factory.rb
librex-0.0.63 lib/rex/thread_factory.rb
librex-0.0.54 lib/rex/thread_factory.rb
librex-0.0.53 lib/rex/thread_factory.rb
librex-0.0.52 lib/rex/thread_factory.rb
librex-0.0.51 lib/rex/thread_factory.rb
librex-0.0.50 lib/rex/thread_factory.rb
librex-0.0.49 lib/rex/thread_factory.rb
librex-0.0.48 lib/rex/thread_factory.rb
librex-0.0.47 lib/rex/thread_factory.rb
librex-0.0.46 lib/rex/thread_factory.rb
librex-0.0.44 lib/rex/thread_factory.rb
librex-0.0.43 lib/rex/thread_factory.rb
librex-0.0.42 lib/rex/thread_factory.rb
librex-0.0.41 lib/rex/thread_factory.rb
librex-0.0.40 lib/rex/thread_factory.rb
librex-0.0.39 lib/rex/thread_factory.rb
librex-0.0.38 lib/rex/thread_factory.rb
librex-0.0.37 lib/rex/thread_factory.rb
librex-0.0.36 lib/rex/thread_factory.rb