Class: Metasploit::Framework::ThreadFactoryProvider

Inherits:
Model::Base
  • Object
show all
Defined in:
lib/metasploit/framework/thread_factory_provider.rb

Overview

Wraps Msf::Framework so that Msf::Framework#threads is only created on the first call to #spawn by Rex::ThreadFactory#spawn, which allows the threads used by Msf::ThreadManager to be created lazily.

Examples:

Setting Rex::ThreadFactory.provider and spawning threads

Rex::ThreadFactory.provider = Metasploit::Framework::ThreadFactoryProvider.new(framework: framework)
# framework.threads created here
Rex::ThreadFactory.spawn("name", false) { ... }

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#frameworkMsf::Framework

The framework managing the spawned threads.

Returns:


18
19
20
# File 'lib/metasploit/framework/thread_factory_provider.rb', line 18

def framework
  @framework
end

Instance Method Details

#spawn(name, critical, *args, &block) ⇒ Object

Spawns a thread monitored by Msf::ThreadManager in Msf::Framework#threads.

(see Msf::ThreadManager#spawn)


23
24
25
# File 'lib/metasploit/framework/thread_factory_provider.rb', line 23

def spawn(name, critical, *args, &block)
  framework.threads.spawn(name, critical, *args, &block)
end