@@ -44,6 +44,7 @@ public:
Functor pre = Functor(),
Functor post = Functor()) {
if (status() >= kStarting && status() < kStopped) return;
+ if (isRunning()) return;
setStatus(kStarting);
thread_ = std::make_shared<std::thread>(&EventLoopThread::loop_thread, this, pre, post);
@@ -298,7 +298,9 @@ public:
// start thread-safe
void start(bool wait_threads_started = true) {
TcpServerEventLoopTmpl<TSocketChannel>::start(wait_threads_started);
- EventLoopThread::start(wait_threads_started);
+ if (!isRunning()) {
+ EventLoopThread::start(wait_threads_started);
+ }
}
// stop thread-safe