UtilsLite
Utilities for C++ programming
Loading...
Searching...
No Matches
Utils::ThreadPool0 Class Reference

Fake thread pool class. More...

#include <ThreadPool0.hxx>

Inheritance diagram for Utils::ThreadPool0:
Utils::ThreadPoolBase

Public Member Functions

 ThreadPool0 (unsigned n)
 Constructs a fake thread pool with a specified number of threads.
 
virtual ~ThreadPool0 ()=default
 Destructor.
 
void exec (FUN &&fun) override
 Executes a given function in the current thread.
 
void wait () override
 No-op method to wait for all tasks to complete.
 
unsigned thread_count () const override
 Returns the number of threads in the pool.
 
char const * name () const override
 
- Public Member Functions inherited from Utils::ThreadPoolBase
 ThreadPoolBase (ThreadPoolBase const &)=delete
 
 ThreadPoolBase (ThreadPoolBase &&)=delete
 
ThreadPoolBaseoperator= (ThreadPoolBase const &)=delete
 
ThreadPoolBaseoperator= (ThreadPoolBase &&)=delete
 
 ThreadPoolBase ()=default
 
template<typename Func, typename... Args>
void run (Func &&func, Args &&... args)
 

Static Public Member Functions

static char const * Name ()
 Returns the name of the thread pool.
 

Additional Inherited Members

- Protected Types inherited from Utils::ThreadPoolBase
typedef std::function< void(void)> FUN
 

Detailed Description

Fake thread pool class.

This class simulates a thread pool by executing tasks in the calling thread, providing a simple interface for task execution without actual multi-threading capabilities.

It is primarily used for testing or environments where threading is not needed.

Constructor & Destructor Documentation

◆ ThreadPool0()

Utils::ThreadPool0::ThreadPool0 ( unsigned n)
inlineexplicit

Constructs a fake thread pool with a specified number of threads.

This constructor initializes the thread pool with a specified number of threads, although it does not actually create any threads. The specified number is ignored.

◆ ~ThreadPool0()

virtual Utils::ThreadPool0::~ThreadPool0 ( )
virtualdefault

Destructor.

Member Function Documentation

◆ exec()

void Utils::ThreadPool0::exec ( FUN && fun)
inlineoverridevirtual

Executes a given function in the current thread.

This method takes a function and executes it immediately in the calling thread. No actual thread pooling is performed.

Parameters
funThe function to be executed.

Implements Utils::ThreadPoolBase.

◆ Name()

static char const * Utils::ThreadPool0::Name ( )
inlinestatic

Returns the name of the thread pool.

This method returns a string describing the type of thread pool.

Returns
A string indicating that this is a "ThreadPool0 (fake thread)".

◆ name()

char const * Utils::ThreadPool0::name ( ) const
inlineoverridevirtual

Implements Utils::ThreadPoolBase.

◆ thread_count()

unsigned Utils::ThreadPool0::thread_count ( ) const
inlineoverridevirtual

Returns the number of threads in the pool.

This method returns the number of threads in the pool, which is always 1 for this fake thread pool.

Returns
Always returns 1.

Implements Utils::ThreadPoolBase.

◆ wait()

void Utils::ThreadPool0::wait ( )
inlineoverridevirtual

No-op method to wait for all tasks to complete.

This method does not perform any actions, as there are no threads or tasks to wait for.

Implements Utils::ThreadPoolBase.


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