Classes | |
| class | BackgroundThread |
| Helper class for running chains of actions on both the main thread and a background thread. More... | |
| class BackgroundThread |
Helper class for running chains of actions on both the main thread and a background thread.
Especially useful for doing ui that also needs networking. Think of it like a JS-like promise chain except with more C++.
Example:
Public Types | |
| typedef BinaryNinja::ProgressFunction | ProgressFunction |
| typedef std::function< QVariant(QVariant value)> | ThenFunction |
| typedef std::function< void(std::exception_ptr exc)> | CatchFunction |
| typedef std::function< void(bool success) > | FinallyFunction |
Signals | |
| void | done (QVariant result) |
| Called when all functions have been run. | |
| void | fail (std::exception_ptr exception) |
| Called when an exception is thrown, after all catch functions have been run. | |
Public Member Functions | |
| void | start (QVariant init=QVariant()) |
| Start the thread and run all its functions in sequence. | |
| void | wait () |
| Block until the thread finishes. | |
| BackgroundThread * | then (BackgroundThread *other) |
| Add another BackgroundThread's functions to the end of this one's. | |
| template<typename Func> | |
| BackgroundThread * | thenBackground (Func &&func) |
| Add a function to run on a background thread. | |
| template<typename Func> | |
| BackgroundThread * | thenMainThread (Func &&func) |
| Add a function to run on the main thread. | |
| template<typename Func> | |
| BackgroundThread * | thenBackgroundWithProgress (QWidget *parent, const QString &title, const QString &text, const QString &cancel, Func &&func) |
| Add a function to run on a background thread, with a progress dialog that blocks the main thread while it runs. | |
| BackgroundThread * | catchBackground (CatchFunction func) |
| Add a function to run on a background thread in the event an exception is thrown. | |
| BackgroundThread * | catchMainThread (CatchFunction func) |
| Add a function to run on the main thread in the event an exception is thrown. | |
| BackgroundThread * | finallyBackground (FinallyFunction func) |
| Add a function to run on a background thread after all other functions, even if something threw. | |
| BackgroundThread * | finallyMainThread (FinallyFunction func) |
| Add a function to run on the main thread after all other functions, even if something threw. | |
Static Public Member Functions | |
| static BackgroundThread * | create (QObject *owner=nullptr) |
| Create a new background thread (but don't start it). | |
| typedef std::function<QVariant(QVariant value)> BackgroundThread::ThenFunction |
| typedef std::function<void(std::exception_ptr exc)> BackgroundThread::CatchFunction |
| typedef std::function<void(bool success) > BackgroundThread::FinallyFunction |
|
inlinestatic |
Create a new background thread (but don't start it).
| owner | QObject that "owns" the thread (or nullptr). If this owner is destroyed, the thread will be terminated before the next callback. |
|
inline |
Start the thread and run all its functions in sequence.
| init | Argument for first function in the thread |
|
inline |
Block until the thread finishes.
|
inline |
Add another BackgroundThread's functions to the end of this one's.
Will move functions out of `other`
| other | BackgroundThread whose functions will be used |
|
inline |
Add a function to run on a background thread.
| func | Function to run on background thread |
|
inline |
Add a function to run on the main thread.
| func | Function to run on main thread |
|
inline |
Add a function to run on a background thread, with a progress dialog that blocks the main thread while it runs.
| parent | Parent widget for progress dialog |
| title | Title of progress dialog |
| text | Text of progress dialog |
| cancel | Cancel button text for progress dialog |
| func | Function to run on background thread, [QVariant|void](QVariant, ProgressTask*, ProgressFunction) |
|
inline |
Add a function to run on a background thread in the event an exception is thrown.
| func | Function to run on background thread |
|
inline |
Add a function to run on the main thread in the event an exception is thrown.
| func | Function to run on main thread |
|
inline |
Add a function to run on a background thread after all other functions, even if something threw.
| func | Function to run on background thread |
|
inline |
Add a function to run on the main thread after all other functions, even if something threw.
| func | Function to run on main thread |
|
signal |
Called when all functions have been run.
| result | Final result |
|
signal |
Called when an exception is thrown, after all catch functions have been run.
| exception | Thrown exception |