YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
yaclib::FairThreadPool Class Reference

TODO(kononovk) Doxygen docs. More...

#include <fair_thread_pool.hpp>

Inheritance diagram for yaclib::FairThreadPool:
[legend]
Collaboration diagram for yaclib::FairThreadPool:
[legend]

Public Member Functions

 FairThreadPool (std::uint64_t threads=yaclib_std::thread::hardware_concurrency())
 
 ~FairThreadPool () noexcept override
 
Type Tag () const noexcept final
 Return type of this executor.
 
bool Alive () const noexcept final
 Return true if executor still alive, that means job passed to submit will be Call.
 
void Submit (Job &task) noexcept final
 Submit given job.
 
void SoftStop () noexcept
 
void Stop () noexcept
 
void HardStop () noexcept
 
void Wait () noexcept
 TODO(kononovk) Rename to Join.
 
- Public Member Functions inherited from yaclib::IRef
virtual void IncRef () noexcept
 Increments reference counter.
 
virtual void DecRef () noexcept
 Decrements reference counter.
 
virtual ~IRef () noexcept=default
 

Additional Inherited Members

- Public Types inherited from yaclib::IExecutor
enum class  Type : unsigned char {
  Custom = 0 , Inline = 1 , Manual = 2 , Strand = 3 ,
  SingleThread = 4 , FairThreadPool = 5 , GolangThreadPool = 6
}
 

Detailed Description

TODO(kononovk) Doxygen docs.

Examples
simple.cpp, strand.cpp, when_all.cpp, and when_any.cpp.

Definition at line 18 of file fair_thread_pool.hpp.

Constructor & Destructor Documentation

◆ FairThreadPool()

yaclib::FairThreadPool::FairThreadPool ( std::uint64_t  threads = yaclib_std::thread::hardware_concurrency())
explicit

Definition at line 6 of file fair_thread_pool.cpp.

References yaclib::MakeContract().

◆ ~FairThreadPool()

yaclib::FairThreadPool::~FairThreadPool ( )
overridenoexcept

Definition at line 15 of file fair_thread_pool.cpp.

References YACLIB_DEBUG.

Member Function Documentation

◆ Alive()

bool yaclib::FairThreadPool::Alive ( ) const
finalvirtualnoexcept

Return true if executor still alive, that means job passed to submit will be Call.

Implements yaclib::IExecutor.

Definition at line 23 of file fair_thread_pool.cpp.

◆ HardStop()

void yaclib::FairThreadPool::HardStop ( )
noexcept

Definition at line 54 of file fair_thread_pool.cpp.

References yaclib::MakeContract(), and Stop().

◆ SoftStop()

void yaclib::FairThreadPool::SoftStop ( )
noexcept

Definition at line 41 of file fair_thread_pool.cpp.

References Stop().

◆ Stop()

void yaclib::FairThreadPool::Stop ( )
noexcept

Definition at line 50 of file fair_thread_pool.cpp.

References Stop().

Referenced by HardStop(), SoftStop(), and Stop().

◆ Submit()

void yaclib::FairThreadPool::Submit ( Job job)
finalvirtualnoexcept

Submit given job.

This method may either Call or Drop the job

This method increments reference counter if task is submitted.

Call if executor is Alive, otherwise Drop

Parameters
jobjob to execute

Implements yaclib::IExecutor.

Definition at line 28 of file fair_thread_pool.cpp.

◆ Tag()

IExecutor::Type yaclib::FairThreadPool::Tag ( ) const
finalvirtualnoexcept

Return type of this executor.

Implements yaclib::IExecutor.

Definition at line 19 of file fair_thread_pool.cpp.

References yaclib::IExecutor::FairThreadPool.

◆ Wait()

void yaclib::FairThreadPool::Wait ( )
noexcept

TODO(kononovk) Rename to Join.

Definition at line 64 of file fair_thread_pool.cpp.

References yaclib::MakeContract().


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