Skip to content

Commit 3883b2d

Browse files
committed
IOThreadTcpService::startWorkerThread return eventloop list
1 parent 7d331b7 commit 3883b2d

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

include/brynet/net/TcpService.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ class IOThreadTcpService : public ITcpService,
3333
return std::make_shared<make_shared_enabler>();
3434
}
3535

36-
void startWorkerThread(size_t threadNum,
37-
FrameCallback callback = nullptr)
36+
std::vector<brynet::net::EventLoop::Ptr> startWorkerThread(size_t threadNum,
37+
FrameCallback callback = nullptr)
3838
{
39-
detail::TcpServiceDetail::startWorkerThread(threadNum, callback);
39+
return detail::TcpServiceDetail::startWorkerThread(threadNum, callback);
4040
}
4141

4242
void stopWorkerThread()

include/brynet/net/detail/TCPServiceDetail.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,17 @@ class TcpServiceDetail : public brynet::base::NonCopyable
6666
stopWorkerThread();
6767
}
6868

69-
void startWorkerThread(size_t threadNum,
70-
FrameCallback callback = nullptr)
69+
std::vector<brynet::net::EventLoop::Ptr> startWorkerThread(size_t threadNum,
70+
FrameCallback callback = nullptr)
7171
{
72+
std::vector<brynet::net::EventLoop::Ptr> eventLoops;
73+
7274
std::lock_guard<std::mutex> lck(mServiceGuard);
7375
std::lock_guard<std::mutex> lock(mIOLoopGuard);
7476

7577
if (!mIOLoopDatas.empty())
7678
{
77-
return;
79+
return eventLoops;
7880
}
7981

8082
mRunIOLoop = std::make_shared<bool>(true);
@@ -84,6 +86,8 @@ class TcpServiceDetail : public brynet::base::NonCopyable
8486
for (auto& v : mIOLoopDatas)
8587
{
8688
auto eventLoop = std::make_shared<EventLoop>();
89+
eventLoops.push_back(eventLoop);
90+
8791
auto runIoLoop = mRunIOLoop;
8892
wg->add(1);
8993
v = IOLoopData::Create(eventLoop,
@@ -103,6 +107,8 @@ class TcpServiceDetail : public brynet::base::NonCopyable
103107
}));
104108
}
105109
wg->wait();
110+
111+
return eventLoops;
106112
}
107113

108114
void stopWorkerThread()

0 commit comments

Comments
 (0)