Encapsulates a task to be executed, and executes it in another thread.
- Copyright
- ESO - European Southern Observatory
Provides a quick way to execute long running procedures in a separate thread. If the user may choose, they can set up connections to signals that are triggered in specific circumstances.
Inherits from QRunnable to handle task setup and wrap-up. Since QRunnable is not a QObject, it cannot have signals and slot: Thus, this is delegated to a WorkerSignals class that is owned by the WorkerIO.
In this example, it is shown how to use this class::
task = Task(function_to_execute)
task.signals.result.connect(function_to_publish_result)
task.signals.finished.connect(function_when_finished)
task.start()
The start() method requests a common QThreadPool to execute this object.
- Note
- This class is intended to simplify threading, and is in no way a complete replacement for all situations.