join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::SpinPolicy< ClockPolicy > Class Template Reference

wheel run policy spinning on a dedicated thread. More...

#include <wheel.hpp>

Public Member Functions

 SpinPolicy (int core=-1, int prio=0) noexcept
 create instance.
 
 SpinPolicy (const SpinPolicy &other)=delete
 copy constructor.
 
SpinPolicy & operator= (const SpinPolicy &other)=delete
 copy assignment operator.
 
 SpinPolicy (SpinPolicy &&other)=delete
 move constructor.
 
SpinPolicy & operator= (SpinPolicy &&other)=delete
 move assignment operator.
 
 ~SpinPolicy () noexcept
 destroy instance.
 
template<class Wheel >
int start (Wheel &wheel, std::chrono::nanoseconds)
 start spinning.
 
void stop () noexcept
 stop spinning.
 
bool isRunnerThread () const noexcept
 check if called from the spinning thread.
 
template<class Wheel >
int flush (Wheel &) noexcept
 no-op.
 
int affinity () const noexcept
 get spinning thread affinity.
 
int priority () const noexcept
 get spinning thread scheduling priority.
 
pthread_t handle () const noexcept
 get the native handle of the spinning thread.
 

Detailed Description

template<class ClockPolicy>
class join::SpinPolicy< ClockPolicy >

wheel run policy spinning on a dedicated thread.

Constructor & Destructor Documentation

◆ SpinPolicy() [1/3]

template<class ClockPolicy >
join::SpinPolicy< ClockPolicy >::SpinPolicy ( int core = -1,
int prio = 0 )
inlineexplicitnoexcept

create instance.

Parameters
corethread core affinity (-1 no pinning).
priothread priority (0 = SCHED_OTHER, 1-99 = SCHED_FIFO).

◆ SpinPolicy() [2/3]

template<class ClockPolicy >
join::SpinPolicy< ClockPolicy >::SpinPolicy ( const SpinPolicy< ClockPolicy > & other)
delete

copy constructor.

Parameters
otherother object to copy.

◆ SpinPolicy() [3/3]

template<class ClockPolicy >
join::SpinPolicy< ClockPolicy >::SpinPolicy ( SpinPolicy< ClockPolicy > && other)
delete

move constructor.

Parameters
otherother object to move.

◆ ~SpinPolicy()

template<class ClockPolicy >
join::SpinPolicy< ClockPolicy >::~SpinPolicy ( )
inlinenoexcept

destroy instance.

Member Function Documentation

◆ affinity()

template<class ClockPolicy >
int join::SpinPolicy< ClockPolicy >::affinity ( ) const
inlinenoexcept

get spinning thread affinity.

Returns
core index, or -1 if not pinned.

◆ flush()

template<class ClockPolicy >
template<class Wheel >
int join::SpinPolicy< ClockPolicy >::flush ( Wheel & )
inlinenoexcept

no-op.

Parameters
wheelwheel to advance.
Returns
0.

◆ handle()

template<class ClockPolicy >
pthread_t join::SpinPolicy< ClockPolicy >::handle ( ) const
inlinenoexcept

get the native handle of the spinning thread.

Returns
pthread_t handle.

◆ isRunnerThread()

template<class ClockPolicy >
bool join::SpinPolicy< ClockPolicy >::isRunnerThread ( ) const
inlinenoexcept

check if called from the spinning thread.

Returns
true if so.

◆ operator=() [1/2]

template<class ClockPolicy >
SpinPolicy & join::SpinPolicy< ClockPolicy >::operator= ( const SpinPolicy< ClockPolicy > & other)
delete

copy assignment operator.

Parameters
otherother object to copy.
Returns
current object.

◆ operator=() [2/2]

template<class ClockPolicy >
SpinPolicy & join::SpinPolicy< ClockPolicy >::operator= ( SpinPolicy< ClockPolicy > && other)
delete

move assignment operator.

Parameters
otherother object to move.
Returns
current object.

◆ priority()

template<class ClockPolicy >
int join::SpinPolicy< ClockPolicy >::priority ( ) const
inlinenoexcept

get spinning thread scheduling priority.

Returns
current priority.

◆ start()

template<class ClockPolicy >
template<class Wheel >
int join::SpinPolicy< ClockPolicy >::start ( Wheel & wheel,
std::chrono::nanoseconds  )
inline

start spinning.

Parameters
wheelwheel to advance, shall outlive the run policy.
periodignored, the loop never sleeps.
Returns
0 on success, -1 on failure.
Exceptions
std::system_errorif the thread cannot be created.

◆ stop()

template<class ClockPolicy >
void join::SpinPolicy< ClockPolicy >::stop ( )
inlinenoexcept

stop spinning.


The documentation for this class was generated from the following files: