CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/metasploit/framework/thread_factory_provider.rb
Views: 1904
1
# Wraps {Msf::Framework} so that {Msf::Framework#threads} is only created on the first call to {#spawn} by
2
# Rex::ThreadFactory#spawn, which allows the threads used by {Msf::ThreadManager} to be created lazily.
3
#
4
# @example Setting Rex::ThreadFactory.provider and spawning threads
5
# Rex::ThreadFactory.provider = Metasploit::Framework::ThreadFactoryProvider.new(framework: framework)
6
# # framework.threads created here
7
# Rex::ThreadFactory.spawn("name", false) { ... }
8
#
9
require 'metasploit_data_models'
10
class Metasploit::Framework::ThreadFactoryProvider < Metasploit::Model::Base
11
#
12
# Attributes
13
#
14
15
# @!attribute framework
16
# The framework managing the spawned threads.
17
#
18
# @return [Msf::Framework]
19
attr_accessor :framework
20
21
# Spawns a thread monitored by {Msf::ThreadManager} in {Msf::Framework#threads}.
22
#
23
# (see Msf::ThreadManager#spawn)
24
def spawn(name, critical, *args, &block)
25
framework.threads.spawn(name, critical, *args, &block)
26
end
27
end
28
29