Search code examples
qtqthread

qt future isRunning() vs isStarted()


what is the difference between them? from docs, it says "currently running" vs "has been started"?

For example, two thread, one is main, the other is called A. If currently, main is running, and A started once(). Will A.isRunning() return false? will A.isStarted() return ture?

what if A never starts?


Solution

  • The docs could be clearer. From reading the source code I can see that it enters Started state once, when the function is first run, and that flag doesn't get cleared (even if task is cancelled). So A.isStarted() should return true. isRunning() however is the actual current state, which depends on current progress (eg. !isFinished()), or is false for example if it was paused or cancelled (or caught an exception).