63 template<
class SERVICE>
70 template<class SERVICE>
71 bool init(std::function<SERVICE *()> creator) noexcept;
74 void start() noexcept;
93 sese::event::EventLoop *event_loop,
94 std::queue<SocketStatus> *master_queue,
95 std::queue<SocketStatus> *slave_queue,
140 if (address ==
nullptr)
return false;
146 if (-1 == socket->getRawSocket()) {
150 if (!socket->setNonblocking()) {
154 if (0 != socket->bind(address)) {
158 if (0 != socket->listen(32)) {
163 masterEventLoop->setListenFd(
static_cast<int>(socket->getRawSocket()));
164 if (!masterEventLoop->init()) {
168 for (
size_t i = 0; i < threads; ++i) {
169 auto event = creator();
170 if (event ==
nullptr) {
173 if (!event->init()) {
177 eventLoopVector.emplace_back(event);
182 masterSocketQueueArray =
new std::queue<SocketStatus>[threads];
183 slaveSocketQueueArray =
new std::queue<SocketStatus>[threads];
184 mutexArray =
new std::mutex[threads];
189 for (
decltype(
auto) event_loop: eventLoopVector) {
192 eventLoopVector.clear();
195 delete masterEventLoop;
196 masterEventLoop =
nullptr;