trantor
Non-blocking I/O cross-platform TCP network library, using C++14
Loading...
Searching...
No Matches
trantor::ConcurrentTaskQueue Class Reference

This class implements a task queue running in parallel. Basically this can be called a threads pool. More...

#include <trantor/utils/ConcurrentTaskQueue.h>

Inheritance diagram for trantor::ConcurrentTaskQueue:
Collaboration diagram for trantor::ConcurrentTaskQueue:

Public Member Functions

 ConcurrentTaskQueue (size_t threadNum, const std::string &name)
 Construct a new concurrent task queue instance.
virtual void runTaskInQueue (const std::function< void()> &task)
 Run a task in the queue.
virtual void runTaskInQueue (std::function< void()> &&task)
virtual std::string getName () const
 Get the name of the queue.
size_t getTaskCount ()
 Get the number of tasks to be executed in the queue.
void stop ()
 Stop all threads in the queue.
Public Member Functions inherited from trantor::TaskQueue
void syncTaskInQueue (const std::function< void()> &task)
 Run a task in the queue synchronously. This means that the task is executed before the method returns.

Additional Inherited Members

Protected Member Functions inherited from trantor::NonCopyable
 NonCopyable (const NonCopyable &)=delete
NonCopyable & operator= (const NonCopyable &)=delete
 NonCopyable (NonCopyable &&) noexcept(true)=default
NonCopyable & operator= (NonCopyable &&) noexcept(true)=default

Detailed Description

This class implements a task queue running in parallel. Basically this can be called a threads pool.

Constructor & Destructor Documentation

◆ ConcurrentTaskQueue()

trantor::ConcurrentTaskQueue::ConcurrentTaskQueue ( size_t threadNum,
const std::string & name )

Construct a new concurrent task queue instance.

Parameters
threadNumThe number of threads in the queue.
nameThe name of the queue.

Member Function Documentation

◆ getName()

virtual std::string trantor::ConcurrentTaskQueue::getName ( ) const
inlinevirtual

Get the name of the queue.

Returns
std::string

Reimplemented from trantor::TaskQueue.

◆ getTaskCount()

size_t trantor::ConcurrentTaskQueue::getTaskCount ( )

Get the number of tasks to be executed in the queue.

Returns
size_t

◆ runTaskInQueue() [1/2]

virtual void trantor::ConcurrentTaskQueue::runTaskInQueue ( const std::function< void()> & task)
virtual

Run a task in the queue.

Parameters
task

Implements trantor::TaskQueue.

◆ runTaskInQueue() [2/2]

virtual void trantor::ConcurrentTaskQueue::runTaskInQueue ( std::function< void()> && task)
virtual

Implements trantor::TaskQueue.


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