Does flexiv::Scheduler::stop return instantly?
Closed this issue · 1 comments
acf986 commented
@pzhu-flexiv
Given the following situation:
- flexiv::Scheduler::start function is called in the main thread to start a worker thread without blocking the main thread.
- Later in the main thread, flexiv::Scheduler::stop is called to stop the worker thread.
My question is:
- Will flexiv::Scheduler::stop return instantly, or it will wait for the worker thread to finish completely (sth like thread.join)?
- Similarly, if the flexiv::Scheduler::start is called without blocking, does it return immediately? or it guarantees the scheduled task thread is already running when the start() function returns?
pzhu-flexiv commented
- Scheduler::stop only sends a stop signal to the running tasks and returns immediately, so no blocking here. The "thread.join" functionality is taken care of by Scheduler::start(true)
- Scheuler::start(false) blocks for a very short period of time to make sure the tasks have already started before returning. So yes, start(false) guarantees the tasks are already running before it returns.