trantor
Non-blocking I/O cross-platform TCP network library, using C++14
Toggle main menu visibility
Loading...
Searching...
No Matches
EventLoopThreadPool.h
Go to the documentation of this file.
1
14
15
#pragma once
16
17
#include <
trantor/net/EventLoopThread.h
>
18
#include <trantor/exports.h>
19
#include <vector>
20
#include <memory>
21
#include <atomic>
22
23
namespace
trantor
24
{
29
class
TRANTOR_EXPORT EventLoopThreadPool : NonCopyable
30
{
31
public
:
32
EventLoopThreadPool() =
delete
;
33
40
EventLoopThreadPool
(
size_t
threadNum,
41
const
std::string &name =
"EventLoopThreadPool"
);
42
47
void
start
();
48
54
void
wait
();
55
61
size_t
size
()
62
{
63
return
loopThreadVector_.size();
64
}
65
71
EventLoop
*
getNextLoop
();
72
80
EventLoop
*
getLoop
(
size_t
id
);
81
87
std::vector<EventLoop *>
getLoops
()
const
;
88
89
private
:
90
std::vector<std::shared_ptr<EventLoopThread>> loopThreadVector_;
91
std::atomic<size_t> loopIndex_{0};
92
};
93
}
// namespace trantor
EventLoopThread.h
trantor::EventLoopThreadPool::getNextLoop
EventLoop * getNextLoop()
Get the next event loop in the pool.
trantor::EventLoopThreadPool::getLoop
EventLoop * getLoop(size_t id)
Get the event loop in the id position in the pool.
trantor::EventLoopThreadPool::wait
void wait()
Wait for all event loops in the pool to quit.
trantor::EventLoopThreadPool::start
void start()
Run all event loops in the pool.
trantor::EventLoopThreadPool::getLoops
std::vector< EventLoop * > getLoops() const
Get all event loops in the pool.
trantor::EventLoopThreadPool::EventLoopThreadPool
EventLoopThreadPool(size_t threadNum, const std::string &name="EventLoopThreadPool")
Construct a new event loop thread pool instance.
trantor::EventLoopThreadPool::size
size_t size()
Return the number of the event loop.
Definition
EventLoopThreadPool.h:61
trantor::EventLoop
As the name implies, this class represents an event loop that runs in a particular thread....
Definition
EventLoop.h:56
trantor
Definition
EventLoop.h:34
trantor
net
EventLoopThreadPool.h
Generated by
1.17.0