Ordering and Threads


order_t

An order_t is a strongly typed std::size_t. This specifies the delay to apply in the event loop in nanoseconds (0 for no delay).


struct zab::order_t

A struct for providing strict typing for timing.

Public Functions

inline constexpr auto operator<=>(const order_t &_other) const

3-way operator for a std::strong_ordering

template<std::integral Integral>
inline constexpr auto operator<=>(const Integral _number) const

3-way operator with a std::integral for a std::strong_ordering

Public Members

std::uint64_t order_ = 0

The amount of time in nanoseconds.

Friends

inline friend constexpr friend auto operator+ (order_t _lhs, order_t _rhs) noexcept

Add two order_t’s together.

Parameters
  • _lhs – The lhs.

  • _rhs – The rhs.

Returns

constexpr auto order_t{lhs.order + rhs.order}

inline friend constexpr friend auto operator- (order_t _lhs, order_t _rhs) noexcept

subtract two order_t’s together.

Parameters
  • _lhs – The lhs.

  • _rhs – The rhs.

Returns

constexpr auto order_t{lhs.order - rhs.order}

thread_t

A thread_t is a strongly typed std::uint16_t which is used to select a thread to be used. This can have different meaning in different contexts. Typically thread_t::any_thread() can be used to select which thread currently has the least amount of work to do. Thread bounds are not checked, so specifying an index larger than the number of threads in the engine is undefined behavior.


struct zab::thread_t

A struct for providing strict typing of thread ids’.

Public Members

std::uint16_t thread_ = kAnyThread

The logical id of the thread.

Public Static Functions

static inline constexpr thread_t any_thread()

Gets a thread_t object with its value initialised to any thread.

Returns

constexpr thread_t

Public Static Attributes

static constexpr auto kAnyThread = std::numeric_limits<std::uint16_t>::max() - 1

This value signifies either no thread or any thread is allowed.

Friends

friend constexpr friend bool operator== (const thread_t _first, const thread_t _second)=default

Equality operator is default.

Parameters
  • _first – The lhs

  • _second – The rhs

Returns

true If equal

Returns

false If not equal

friend constexpr friend bool operator!= (const thread_t _first, const thread_t _second)=default

Inequality operator is default.

Parameters
  • _first – The lhs.

  • _second – The rhs.

Returns

true If not equal

Returns

false If equal

inline friend constexpr friend auto operator<=> (const thread_t _first, const thread_t _second)

3-way operator is default for a std::strong_ordering.

Parameters
  • _first – The lhs.

  • _second – The rhs.

template<std::integral T> inline friend constexpr friend auto operator<=> (const thread_t _first, const T _number)

3-way operator with a std::integral for a std::strong_ordering.

Parameters
  • _first – The lhs.

  • _second – The rhs.

template<std::integral T> inline friend constexpr friend bool operator== (const thread_t _first, const T _second)

Equality operator with a std::integral.

Parameters
  • _first – The lhs

  • _second – The rhs

Returns

true If equal

Returns

false If not equal

template<std::integral T> inline friend constexpr friend bool operator!= (const thread_t &_first, const T _second)

Inequality operator with a std::integral.

Parameters
  • _first – The lhs

  • _second – The rhs

Returns

true If equal

Returns

false If not equal