flexivrobotics/flexiv_rdk

Does flexiv::Scheduler::stop return instantly?

Closed this issue · 1 comments

acf986 commented

@pzhu-flexiv
Given the following situation:

  1. flexiv::Scheduler::start function is called in the main thread to start a worker thread without blocking the main thread.
  2. Later in the main thread, flexiv::Scheduler::stop is called to stop the worker thread.

My question is:

  1. Will flexiv::Scheduler::stop return instantly, or it will wait for the worker thread to finish completely (sth like thread.join)?
  2. 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?

@acf986

  1. 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)
  2. 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.