Closed caistd closed 7 years ago
Use loop.Stop()
to exit. For example:
auto f = [&loop]() {
loop.Stop();
};
loop.RunAfter(evpp::Duration(10.0), f);
Is there a manual?
Sorry, we don't have a manual. Please read the example source codes.
loop.RunAfter(evpp::Duration(1.0), [&loop] { loop.Stop(); });
is ok
auto f = [&loop]() {
loop.Stop();
};
loop.RunAfter(evpp::Duration(10.0), f);
[ &loop] lambda Unable to capture variables why
auto f = &loop {
loop.Stop();
};
That lambda's format is wrong. The right way to define a lambda is :
auto f = [&loop]() {
loop.Stop();
};
thankyou Is there any other way to solve it? and What's the difference between event_loop_thread.h and event_loop_thread_pool.h in multiple threads ?
EventLoopThread is one thread, EventLoopThreadPool is a thread pool which holds multi threads.
How to create multithreaded?
Please see the API. e.g. evpp::TCPServer(&loop, addr, "TCPEcho", 12)
will create a thread pool with 12 threads in it.
what is PostTask
?
// @brief Join the thread. If you forget to call this method,
// it will be invoked automatically in the destruct method ~EventLoopThread().
// @note DO NOT call this method from any of the working thread.
void Join();
Causes the thread to fail
// @brief Join the thread. If you forget to call this method, // it will be invoked automatically in the destruct method ~EventLoopThread(). // @note DO NOT call this method from any of the working thread. void Join();
EventLoopThread::~EventLoopThread() { DLOG_TRACE << "loop=" << eventloop; assert(IsStopped()); Join(); } Causes the thread to fail