AsyncDataAccess
#include <bb/data/AsyncDataAccess>
To link against this class, add the following line to your .pro file: LIBS += -lbbdata
Allows communication with an asynchronous worker in another thread.
The AsyncDataAccess class allows an application to communicate with an asynchronous worker object that's performing long-running operations while running in another thread.
SqlConnection for examples of usage.
BlackBerry 10.0.0
Inheritance
| bb::data::AsyncDataAccess | |||
| bb::data::SqlConnection | |||
Public Functions Index
| AsyncDataAccess (AsyncWorker *worker, QObject *parent=0) | |
| virtual | ~AsyncDataAccess () |
| void | start (QThread::Priority priority=QThread::LowPriority) |
| void | execute (const QVariant &criteria, int id=0) |
| DataAccessReply | executeAndWait (const QVariant &criteria, int id=0) |
| void | stop () |
| bool | isRunning () |
Signals Index
| void | reply (const bb::data::DataAccessReply &replyData) |
Public Functions
Constructs a data access "service" object which will run the given worker task in another thread.
If not 0, the ownership of this object will be transferred to the parent. Also, ownership of the worker will always be managed by this async framework and so the ownership of the worker will be transferred to an internal object in this framework which has affinity for the new thread.
| Parameters | |
|---|---|
| worker |
The class which will execute work in another thread. |
| parent |
The parent owner or 0. Optional and will default to 0 if not specified. |
BlackBerry 10.0.0
virtual
Destructor.
BlackBerry 10.0.0
void
Starts the asynchronous worker in another thread, ready to accept work.
If not started explicitly, the worker will be started when the first work is executed.
| Parameters | |
|---|---|
| priority |
The priority of the thread, specified by QThread::Priority. The default value is QThread::LowPriority. |
BlackBerry 10.0.0
void
Passes the specified criteria data to the asynchronous worker and queues for execution.
This method returns immediately. Results will be returned in a DataAccessReply object using the reply() signal in this class.
If the thread has not been started, this method will call start().
| Parameters | |
|---|---|
| criteria |
The criteria data that is passed to the worker to specify the work to be done. |
| id |
An ID that's used to help match this request with a particular reply. The DataAccessReply will contain this ID. Defaults to 0 if not specified. |
BlackBerry 10.0.0
DataAccessReply
Passes the specified criteria data to the asynchronous worker for execution.
The current thread will block until a DataAccessReply object can be returned.
If the thread has not been started, this function will call start().
| Parameters | |
|---|---|
| criteria |
The criteria data that is passed to the worker to specify the work to be done. |
| id |
An ID that's used to help match this request with its reply. The DataAccessReply that's returned will contain this ID. Defaults to 0 if not specified. |
A DataAccessReply containing the results of the operation.
BlackBerry 10.0.0
void
Stops the thread that's performing the asynchronous work.
You can call start() again to initiate a new thread using the same async worker.
BlackBerry 10.0.0
bool
Indicates whether the thread that's performing the asynchronous work is currently running.
true if the thread is currently running, false otherwise.
BlackBerry 10.0.0
Signals
void
Emitted when an asynchronous execute operation has completed and has results to return.
| Parameters | |
|---|---|
| replyData |
The reply data from the execute operation. |
BlackBerry 10.0.0