Class ThreadPool
Defined in File system_resources.hpp
Base Type
public holoscan::gxf::GXFSystemResourceBase
(Class GXFSystemResourceBase)
-
class ThreadPool : public holoscan::gxf::GXFSystemResourceBase
Thread pool resource.
This is a thread pool for use with the EventBasedScheduler or MultiThreadScheduler. This resource should be created via the
Fragment::make_thread_pool
method instead of the usualFragment::make_resource
method as it requires additional configuration of an associated GXF EntityGroup.pool1 = make_thread_pool(“pool1”, Arg(“initial_size”, static_cast<int64_t>(2)));
The operators can be added via the
add
method. For strict thread pinning, thepin_operator
argument should be true and the initial_size of the thread pool should be at least as large as the number of operators that will be pinned to threads.pool1.add(op1, true); pool1.add(op2, true);
This add method takes care of adding any needed holoscan::CPUThread resource to the operator.
The MultiThreadScheduler’s
strict_job_thread_pinning
argument can be set true to disallow execution of any other entities on the pinned thread. The EventBasedScheduler always uses strict thread pinning.Public Functions
-
template<typename ArgT, typename ...ArgsT, typename = std::enable_if_t<!std::is_base_of_v<::holoscan::Resource, std::decay_t<ArgT>> && (std::is_same_v<::holoscan::Arg, std::decay_t<ArgT>> || std::is_same_v<::holoscan::ArgList, std::decay_t<ArgT>>)>>
inline explicit ThreadPool(ArgT &&arg, ArgsT&&... args)
-
ThreadPool() = default
-
ThreadPool(const std::string &name, nvidia::gxf::ThreadPool *component)
-
inline virtual const char *gxf_typename() const override
The underlying GXF component’s name.
-
virtual void setup(ComponentSpec &spec) override
Define the resource specification.
- Parameters
spec – The reference to the component specification.
-
int64_t size() const
The number of threads currently in the thread pool.
Add an operator to the thread pool.
- Parameters
op – The operator to add.
pin_operator – Whether the operator should be pinned to a specific thread in the pool.
Add multiple operators to the thread pool.
- Parameters
op – The operators to add.
pin_operator – Whether the operators should be pinned to a specific thread in the pool.
-
inline std::shared_ptr<gxf::EntityGroup> entity_group() const
-
inline std::vector<std::shared_ptr<Operator>> operators() const
The operators associated with this thread pool.
-
virtual YAML::Node to_yaml_node() const override
Get a YAML representation of the thread pool.
- Returns
YAML node including properties of the base resource and the operators in the pool.
Protected Functions
Set the entity group for this thread pool.
Friends
- friend class Fragment
-
template<typename ArgT, typename ...ArgsT, typename = std::enable_if_t<!std::is_base_of_v<::holoscan::Resource, std::decay_t<ArgT>> && (std::is_same_v<::holoscan::Arg, std::decay_t<ArgT>> || std::is_same_v<::holoscan::ArgList, std::decay_t<ArgT>>)>>