omni::core::Generated< omni::experimental::job::IJobAffinity_abi >
Defined in omni/experimental/job/IJob.gen.h
-
template<>
class Generated<omni::experimental::job::IJobAffinity_abi> : public omni::experimental::job::IJobAffinity_abi Interface for setting CPU affinity for the job system.
Public Functions
-
inline omni::core::ObjectPtr<omni::experimental::job::IAffinityMask> get_affinity(size_t worker_id) noexcept
Gets the current affinity of a worker.
- Parameters
worker_id – The worker to set the affinity of. If this id is larger than the current number of workers, a
nullptr
will be returned.- Returns
The current affinity being used by the worker. The returned value may be
nullptr
if the worker’s affinity could not be determined.
-
inline bool set_affinity(size_t worker_id, omni::core::ObjectParam<omni::experimental::job::IAffinityMask> mask) noexcept
Attempts to set the affinity for the specified worker.
Note
On Windows each thread can only belong to a single Processor Group, so the CPU Affinity will only be set to the first non-zero entry. That is to say, if both
mask->get_affinity_mask(0)
andmask->get_affinity_mask(1)
both have bits sets, only the CPUs inmask->get_affinity_mask(0)
will be set for the affinity.- Parameters
worker_id – The worker to set the affinity of. If this id is larger than the current number of workers, false will be returned.
mask – The affinity values to set.
- Returns
true if the affinity was successfully set, false otherwise.
-
inline void *cast(omni::core::TypeId id) noexcept
Returns a pointer to the interface defined by the given type id if this object implements the type id’s interface.
Objects can support multiple interfaces, even interfaces that are in different inheritance chains.
The returned object will have omni::core::IObject::acquire() called on it before it is returned, meaning it is up to the caller to call omni::core::IObject::release() on the returned pointer.
The returned pointer can be safely
reinterpret_cast<>
to the type id’s C++ class. For example, “omni.windowing.IWindow” can be cast toomni::windowing::IWindow
.Do not directly use this method, rather use a wrapper function like omni::core::cast() or omni::core::ObjectPtr::as().
- Thread Safety
This method is thread safe.
-
inline void acquire() noexcept
Increments the object’s reference count.
Objects may have multiple reference counts (e.g. one per interface implemented). As such, it is important that you call omni::core::IObject::release() on the same pointer from which you called omni::core::IObject::acquire().
Do not directly use this method, rather use omni::core::ObjectPtr, which will manage calling omni::core::IObject::acquire() and omni::core::IObject::release() for you.
- Thread Safety
This method is thread safe.
-
inline void release() noexcept
Decrements the objects reference count.
Most implementations will destroy the object if the reference count reaches 0 (though this is not a requirement).
Objects may have multiple reference counts (e.g. one per interface implemented). As such, it is important that you call omni::core::IObject::release() on the same pointer from which you called omni::core::IObject::acquire().
Do not directly use this method, rather use omni::core::ObjectPtr, which will manage calling omni::core::IObject::acquire() and omni::core::IObject::release() for you.
- Thread Safety
This method is thread safe.
Protected Functions
-
virtual IAffinityMask *get_affinity_abi(size_t worker_id) noexcept = 0
Gets the current affinity of a worker.
- Parameters
worker_id – The worker to set the affinity of. If this id is larger than the current number of workers, a
nullptr
will be returned.- Returns
The current affinity being used by the worker. The returned value may be
nullptr
if the worker’s affinity could not be determined.
-
virtual bool set_affinity_abi(size_t worker_id, IAffinityMask *mask) noexcept = 0
Attempts to set the affinity for the specified worker.
Note
On Windows each thread can only belong to a single Processor Group, so the CPU Affinity will only be set to the first non-zero entry. That is to say, if both
mask->get_affinity_mask(0)
andmask->get_affinity_mask(1)
both have bits sets, only the CPUs inmask->get_affinity_mask(0)
will be set for the affinity.- Parameters
worker_id – The worker to set the affinity of. If this id is larger than the current number of workers, false will be returned.
mask – The affinity values to set.
- Returns
true if the affinity was successfully set, false otherwise.
-
virtual void *cast_abi(TypeId id) noexcept = 0
Returns a pointer to the interface defined by the given type id if this object implements the type id’s interface.
Objects can support multiple interfaces, even interfaces that are in different inheritance chains.
The returned object will have omni::core::IObject::acquire() called on it before it is returned, meaning it is up to the caller to call omni::core::IObject::release() on the returned pointer.
The returned pointer can be safely
reinterpret_cast<>
to the type id’s C++ class. For example, “omni.windowing.IWindow” can be cast toomni::windowing::IWindow
.Do not directly use this method, rather use a wrapper function like omni::core::cast() or omni::core::ObjectPtr::as().
- Thread Safety
This method is thread safe.
-
virtual void acquire_abi() noexcept = 0
Increments the object’s reference count.
Objects may have multiple reference counts (e.g. one per interface implemented). As such, it is important that you call omni::core::IObject::release() on the same pointer from which you called omni::core::IObject::acquire().
Do not directly use this method, rather use omni::core::ObjectPtr, which will manage calling omni::core::IObject::acquire() and omni::core::IObject::release() for you.
- Thread Safety
This method is thread safe.
-
virtual void release_abi() noexcept = 0
Decrements the objects reference count.
Most implementations will destroy the object if the reference count reaches 0 (though this is not a requirement).
Objects may have multiple reference counts (e.g. one per interface implemented). As such, it is important that you call omni::core::IObject::release() on the same pointer from which you called omni::core::IObject::acquire().
Do not directly use this method, rather use omni::core::ObjectPtr, which will manage calling omni::core::IObject::acquire() and omni::core::IObject::release() for you.
- Thread Safety
This method is thread safe.
-
inline omni::core::ObjectPtr<omni::experimental::job::IAffinityMask> get_affinity(size_t worker_id) noexcept