Heart 1.3.842.34c2ab5
Heart is base back end library for your c++ Qt projects.
QH::AsyncLauncher Class Referencefinal

The AsyncLauncher class is wraper of the Async class for support moving invokes to thread of the current object. More...

#include <asynclauncher.h>

Inheritance diagram for QH::AsyncLauncher:
Inheritance graph
Collaboration diagram for QH::AsyncLauncher:
Collaboration graph

Public Member Functions

 AsyncLauncher (QThread *thread, QObject *ptr=nullptr)
 AsyncLauncher This is base constructor of the AsyncLauncher object.
 
bool run (const Job &action, bool wait=false)
 run This method run the action function in the work thread of this object.
 
- Public Member Functions inherited from QH::Async
bool asyncLauncher (const Job &job, bool await=false, bool freaze=true) const
 asyncLauncher This method invoke a job on the thread (using the asyncHandler method) of this object.
 

Additional Inherited Members

- Public Types inherited from QH::Async
using Job = std::function< bool()>
 
- Protected Member Functions inherited from QH::Async
 Async (QThread *thread, QObject *ptr=nullptr)
 Async This is default constructor of the async object.
 
 ~Async ()
 
bool waitFor (bool *condition, int timeout=WAIT_TIME, bool freaze=true) const
 waitFor This is base wait function.
 
bool waitFor (const Job &condition, int timeout=WAIT_TIME, bool freaze=true) const
 waitFor This is base wait function.
 

Detailed Description

The AsyncLauncher class is wraper of the Async class for support moving invokes to thread of the current object.

Note
For create this object use the AsyncFacrtory class. Exmaple:
QThread *thread = new QThread();
AsyncLauncher *async = AsyncFacrtory::makeAsyncObject<AsyncLauncher>(thread);
AsyncLauncher::Job action = []() -> bool {
...
}
async->run(action);
The AsyncLauncher class is wraper of the Async class for support moving invokes to thread of the curr...
bool run(const Job &action, bool wait=false)
run This method run the action function in the work thread of this object.
std::function< bool()> Job
Definition async.h:35

Definition at line 31 of file asynclauncher.h.

Constructor & Destructor Documentation

◆ AsyncLauncher()

QH::AsyncLauncher::AsyncLauncher ( QThread *  thread,
QObject *  ptr = nullptr 
)

AsyncLauncher This is base constructor of the AsyncLauncher object.

Parameters
threadThis is pointer to the work thread. If you want to change thread in run time just use the setThread method.
ptrThis is QObject parent.

Definition at line 11 of file asynclauncher.cpp.

Member Function Documentation

◆ run()

bool QH::AsyncLauncher::run ( const Job action,
bool  wait = false 
)

run This method run the action function in the work thread of this object.

Parameters
actionThis is function for running in the work thread.
waitThis option for sets awaiting of the finishing the action function. By default this is false.
Returns
true if the action started succesful when wait is false and return true if the action finished succesful if the wait is true.

Definition at line 16 of file asynclauncher.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: