Path: blob/master/lib/metasploit/framework/thread_factory_provider.rb
19612 views
# Wraps {Msf::Framework} so that {Msf::Framework#threads} is only created on the first call to {#spawn} by1# Rex::ThreadFactory#spawn, which allows the threads used by {Msf::ThreadManager} to be created lazily.2#3# @example Setting Rex::ThreadFactory.provider and spawning threads4# Rex::ThreadFactory.provider = Metasploit::Framework::ThreadFactoryProvider.new(framework: framework)5# # framework.threads created here6# Rex::ThreadFactory.spawn("name", false) { ... }7#8require 'metasploit_data_models'9class Metasploit::Framework::ThreadFactoryProvider < Metasploit::Model::Base10#11# Attributes12#1314# @!attribute framework15# The framework managing the spawned threads.16#17# @return [Msf::Framework]18attr_accessor :framework1920# Spawns a thread monitored by {Msf::ThreadManager} in {Msf::Framework#threads}.21#22# (see Msf::ThreadManager#spawn)23def spawn(name, critical, *args, &block)24framework.threads.spawn(name, critical, *args, &block)25end26end272829