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

The Async class This is bundle of async templates and async wrappers. More...

#include <async.h>

Inheritance diagram for QH::Async:
Inheritance graph
Collaboration diagram for QH::Async:
Collaboration graph

Public Types

using Job = std::function< bool()>
 

Public Member Functions

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.
 

Protected Member Functions

 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 Async class This is bundle of async templates and async wrappers.

Note
If you use this object then you do not need include QObject because this class include the QObject class. Do not forget the Q_OBJECT macross.
All objects of this class must be initialized with the . So The constructor is private and the AsynFactyry class is a friend class of the Async class.

Definition at line 26 of file async.h.

Member Typedef Documentation

◆ Job

using QH::Async::Job = std::function<bool()>

The Job is wrapper of the std::function<bool()> type. This type registered like the Qt meta type For using in the qt metasystem.

Definition at line 35 of file async.h.

Constructor & Destructor Documentation

◆ Async()

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

Async This is default constructor of the async object.

Parameters
threadThis is work thread of the async object.
ptrThis is pointer to qtparent of this object.
Note
thread must be different of the main thread.

Definition at line 38 of file async.cpp.

◆ ~Async()

QH::Async::~Async ( )
protected
Note
This is async distructor. This distructor wait for finishing of the own threads befor delete.

Definition at line 45 of file async.cpp.

Member Function Documentation

◆ asyncLauncher()

bool QH::Async::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.

Parameters
jobThis is function with needed job.
awaitThis is boolean option for enable or disable wait for finish of the job function.
freazeThis option disaable process event of waiting of results.
Returns
true if the job function started correctly. If the await option is true then this method return result of job function.

Definition at line 80 of file async.cpp.

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

◆ waitFor() [1/2]

bool QH::Async::waitFor ( bool *  condition,
int  timeout = WAIT_TIME,
bool  freaze = true 
) const
protected

waitFor This is base wait function.

Parameters
conditionThis is pointer to awaiting boolean variable.
timeoutThis is maximum time for wait. By default this value equals WAIT_TIME it is 30000 msec.
freazeThis frease current thread for waiting results of another thread. If you set this option to false then will be invoked process event method.
Returns
true if condition is true.

Definition at line 69 of file async.cpp.

Here is the caller graph for this function:

◆ waitFor() [2/2]

bool QH::Async::waitFor ( const Job condition,
int  timeout = WAIT_TIME,
bool  freaze = true 
) const
protected

waitFor This is base wait function.

Parameters
conditionThis is lambda method with condition results.
timeoutThis is maximum time for wait. By default this value equals WAIT_TIME it is 30000 msec.
freazeThis frease current thread for waiting results of another thread. If you set this option to false then will be invoked process event method.
Returns
true if condition is true.

Definition at line 121 of file async.cpp.


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