Class CPUThread
Defined in File cpu_thread.hpp
Base Type
public holoscan::gxf::GXFResource
(Class GXFResource)
-
class CPUThread : public holoscan::gxf::GXFResource
CPU thread class.
A CPUThread resource can be added to an operator to control whether it will be pinned to a specific thread in a ThreadPool (as used by MultiThreadScheduler). See the ThreadPool API documentation for a more detailed description of its usage.
Application authors should not need to use this class directly. It is used behind the scenes as needed by the
holoscan::ThreadPool
class.==Parameters==
pin_entity (bool, optional): Whether or not an operator should be pinned to a specific thread (Default: false).
pin_cores (std::vector<uint32_t>, optional): CPU core IDs to pin the worker thread to. Empty vector means no core pinning (Default: empty).
sched_policy (SchedulingPolicy, optional): Linux real-time scheduling policy. kFirstInFirstOut is SCHED_FIFO, kRoundRobin is SCHED_RR, kDeadline is SCHED_DEADLINE (Default: not set).
sched_priority (uint32_t, optional): Thread priority for FirstInFirstOut and RoundRobin policies (Default: not set).
sched_runtime (uint64_t, optional): Expected worst case execution time in nanoseconds for Deadline policy (Default: not set).
sched_deadline (uint64_t, optional): Relative deadline in nanoseconds for Deadline policy (Default: not set).
sched_period (uint64_t, optional): Period in nanoseconds for Deadline policy (Default: not set).
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 CPUThread(ArgT &&arg, ArgsT&&... args)
-
inline explicit CPUThread(bool pin_entity = true)
-
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.
-
virtual void initialize() override
Initialize the component.
This method is called only once when the component is created for the first time, and use of light-weight initialization.
-
bool pinned() const
Returns whether the component is pinned to a worker thread.
-
std::vector<uint32_t> pin_cores() const
CPU core IDs to pin the worker thread to (empty means no core pinning).
-
holoscan::expected<SchedulingPolicy, holoscan::RuntimeError> sched_policy() const
Real-time scheduling policy.
-
holoscan::expected<uint32_t, holoscan::RuntimeError> sched_priority() const
Thread priority (only for FirstInFirstOut and RoundRobin policies).
-
holoscan::expected<uint64_t, holoscan::RuntimeError> sched_runtime() const
Expected worst case execution time in nanoseconds (only for Deadline policy).
-
holoscan::expected<uint64_t, holoscan::RuntimeError> sched_deadline() const
Relative deadline in nanoseconds (only for Deadline policy).
-
holoscan::expected<uint64_t, holoscan::RuntimeError> sched_period() const
Period in nanoseconds (only for Deadline policy).
-
bool is_realtime() const
Helper method to check if real-time scheduling is enabled.