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

This class represents a pool of EventLoopThread objects. More...

#include <trantor/net/EventLoopThreadPool.h>

Inheritance diagram for trantor::EventLoopThreadPool:
Collaboration diagram for trantor::EventLoopThreadPool:

Public Member Functions

 EventLoopThreadPool (size_t threadNum, const std::string &name="EventLoopThreadPool")
 Construct a new event loop thread pool instance.
void start ()
 Run all event loops in the pool.
void wait ()
 Wait for all event loops in the pool to quit.
size_t size ()
 Return the number of the event loop.
EventLoopgetNextLoop ()
 Get the next event loop in the pool.
EventLoopgetLoop (size_t id)
 Get the event loop in the id position in the pool.
std::vector< EventLoop * > getLoops () const
 Get all event loops in the pool.

Detailed Description

This class represents a pool of EventLoopThread objects.

Constructor & Destructor Documentation

◆ EventLoopThreadPool()

trantor::EventLoopThreadPool::EventLoopThreadPool ( size_t threadNum,
const std::string & name = "EventLoopThreadPool" )

Construct a new event loop thread pool instance.

Parameters
threadNumThe number of threads
nameThe name of the EventLoopThreadPool object.

Member Function Documentation

◆ getLoop()

EventLoop * trantor::EventLoopThreadPool::getLoop ( size_t id)

Get the event loop in the id position in the pool.

Parameters
idThe id of the first event loop is zero. If the id >= the number of event loops, nullptr is returned.
Returns
EventLoop*

◆ getLoops()

std::vector< EventLoop * > trantor::EventLoopThreadPool::getLoops ( ) const

Get all event loops in the pool.

Returns
std::vector<EventLoop *>

◆ getNextLoop()

EventLoop * trantor::EventLoopThreadPool::getNextLoop ( )

Get the next event loop in the pool.

Returns
EventLoop*

◆ size()

size_t trantor::EventLoopThreadPool::size ( )
inline

Return the number of the event loop.

Returns
size_t

◆ start()

void trantor::EventLoopThreadPool::start ( )

Run all event loops in the pool.

Note
This function doesn't block the current thread.

◆ wait()

void trantor::EventLoopThreadPool::wait ( )

Wait for all event loops in the pool to quit.

Note
This function blocks the current thread.

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