Zth (libzth)
zth::Worker Class Reference

The class that manages the fibers within this thread. More...

#include <worker.h>

Inheritance diagram for zth::Worker:
zth::UniqueID< Worker > zth::ThreadLocalSingleton< Worker > zth::UniqueIDBase

Public Types

typedef Load Load_type
 
- Public Types inherited from zth::ThreadLocalSingleton< Worker >
typedef Worker singleton_type
 Alias of the T template parameter. More...
 

Public Member Functions

 Worker ()
 
virtual ~Worker () override
 
FibercurrentFiber () const noexcept
 
Waiterwaiter () noexcept
 
void add (Fiber *fiber) noexcept
 
Workeroperator<< (Fiber *fiber) noexcept
 
void contextSwitchEnable (bool enable=true) noexcept
 
void contextSwitchDisable () noexcept
 
bool contextSwitchEnabled () const noexcept
 
void release (Fiber &fiber) noexcept
 
bool schedule (Fiber *preferFiber=nullptr, Timestamp const &now=Timestamp::now())
 
void cleanup (Fiber &fiber)
 
void suspend (Fiber &fiber)
 
void resume (Fiber &fiber) noexcept
 
Timestamp const & runEnd () const noexcept
 
void run (TimeInterval const &duration=TimeInterval())
 
Load_typeload () noexcept
 
Load_type const & load () const noexcept
 
- Public Member Functions inherited from zth::UniqueID< Worker >
 UniqueID (UniqueID const &)=delete
 
 UniqueID (UniqueID &&u) noexcept
 
 UniqueID (string const &name)
 
 UniqueID (string &&name)
 
 UniqueID (char const *name=nullptr)
 
UniqueIDoperator= (UniqueID const &)=delete
 
UniqueIDoperator= (UniqueID &&u) noexcept
 
virtual ~UniqueID ()=default
 
void const * normptr () const noexcept
 
uint64_t id () const noexcept
 
string const & name () const noexcept
 
void setName (string const &name)
 
void setName (char const *name)
 
void setName (string &&name)
 
virtual char const * id_str () const override
 

Protected Member Functions

bool isInWorkerContext () const noexcept
 
void dbgStats () noexcept
 
- Protected Member Functions inherited from zth::UniqueIDBase
virtual ~UniqueIDBase ()=default
 
- Protected Member Functions inherited from zth::ThreadLocalSingleton< Worker >
 ThreadLocalSingleton ()
 Constructor. More...
 
 ~ThreadLocalSingleton ()
 Destructor. More...
 

Static Protected Member Functions

static void dummyWorkerEntry (void *)
 

Friends

void worker_global_init ()
 

Additional Inherited Members

- Static Public Member Functions inherited from zth::UniqueID< Worker >
static uint64_t getID () noexcept
 
- Static Public Member Functions inherited from zth::ThreadLocalSingleton< Worker >
static safe_ptr< singleton_type >::type instance () noexcept
 Return the only instance of T within this thread. More...
 

Detailed Description

The class that manages the fibers within this thread.

Examples
socks.cpp.

Definition at line 36 of file worker.h.

Member Typedef Documentation

◆ Load_type

Definition at line 326 of file worker.h.

Constructor & Destructor Documentation

◆ Worker()

zth::Worker::Worker ( )
inline

Definition at line 41 of file worker.h.

◆ ~Worker()

virtual zth::Worker::~Worker ( )
inlineoverridevirtual

Definition at line 78 of file worker.h.

Member Function Documentation

◆ add()

void zth::Worker::add ( Fiber fiber)
inlinenoexcept

Definition at line 106 of file worker.h.

◆ cleanup()

void zth::Worker::cleanup ( Fiber fiber)
inline

Definition at line 236 of file worker.h.

◆ contextSwitchDisable()

void zth::Worker::contextSwitchDisable ( )
inlinenoexcept

Definition at line 137 of file worker.h.

◆ contextSwitchEnable()

void zth::Worker::contextSwitchEnable ( bool  enable = true)
inlinenoexcept

Definition at line 128 of file worker.h.

◆ contextSwitchEnabled()

bool zth::Worker::contextSwitchEnabled ( ) const
inlinenoexcept

Definition at line 142 of file worker.h.

◆ currentFiber()

Fiber* zth::Worker::currentFiber ( ) const
inlinenoexcept

Definition at line 96 of file worker.h.

◆ dbgStats()

void zth::Worker::dbgStats ( )
inlineprotectednoexcept

Definition at line 349 of file worker.h.

◆ dummyWorkerEntry()

static void zth::Worker::dummyWorkerEntry ( void *  )
inlinestaticprotected

Definition at line 339 of file worker.h.

◆ isInWorkerContext()

bool zth::Worker::isInWorkerContext ( ) const
inlineprotectednoexcept

Definition at line 344 of file worker.h.

◆ load() [1/2]

Load_type const& zth::Worker::load ( ) const
inlinenoexcept

Definition at line 333 of file worker.h.

◆ load() [2/2]

Load_type& zth::Worker::load ( )
inlinenoexcept

Definition at line 328 of file worker.h.

◆ operator<<()

Worker& zth::Worker::operator<< ( Fiber fiber)
inlinenoexcept

Definition at line 122 of file worker.h.

◆ release()

void zth::Worker::release ( Fiber fiber)
inlinenoexcept

Definition at line 147 of file worker.h.

◆ resume()

void zth::Worker::resume ( Fiber fiber)
inlinenoexcept

Definition at line 291 of file worker.h.

◆ run()

void zth::Worker::run ( TimeInterval const &  duration = TimeInterval())
inline
Examples
socks.cpp.

Definition at line 306 of file worker.h.

◆ runEnd()

Timestamp const& zth::Worker::runEnd ( ) const
inlinenoexcept

Definition at line 301 of file worker.h.

◆ schedule()

bool zth::Worker::schedule ( Fiber preferFiber = nullptr,
Timestamp const &  now = Timestamp::now() 
)
inline

Definition at line 164 of file worker.h.

◆ suspend()

void zth::Worker::suspend ( Fiber fiber)
inline

Definition at line 265 of file worker.h.

◆ waiter()

Waiter& zth::Worker::waiter ( )
inlinenoexcept

Definition at line 101 of file worker.h.

Friends And Related Function Documentation

◆ worker_global_init

void worker_global_init ( )
friend

Definition at line 34 of file worker.cpp.


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