AsyncDataAccess

Since: BlackBerry 10.0.0

#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.

See also:

SqlConnection for examples of usage.


Overview

Inheritance

bb::data::AsyncDataAccess
bb::data::SqlConnection

Public Functions Index

AsyncDataAccess (AsyncWorker *worker, QObject *parent=0)
virtual ~AsyncDataAccess ()
voidexecute (const QVariant &criteria, int id=0)
DataAccessReplyexecuteAndWait (const QVariant &criteria, int id=0)
boolisRunning ()
voidstart (QThread::Priority priority=QThread::LowPriority)
voidstop ()

Signals Index

voidreply (const bb::data::DataAccessReply &replyData)

Public Functions

AsyncDataAccess (

Constructs a data access "service" object which will run the given worker task in another 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.

Since:

BlackBerry 10.0.0

virtual~AsyncDataAccess ()

Destructor.

Since:

BlackBerry 10.0.0

void execute (

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.

Since:

BlackBerry 10.0.0

DataAccessReply executeAndWait (

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.

Return:

A DataAccessReply containing the results of the operation.

Since:

BlackBerry 10.0.0

bool isRunning ()

Indicates whether the thread that's performing the asynchronous work is currently running.

Return:

true if the thread is currently running, false otherwise.

Since:

BlackBerry 10.0.0

void start (
  • QThread::Prioritypriority)

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.

Since:

BlackBerry 10.0.0

void stop ()

Stops the thread that's performing the asynchronous work.

You can call start() again to initiate a new thread using the same async worker.

Since:

BlackBerry 10.0.0

Signals

void reply (

Emitted when an asynchronous execute operation has completed and has results to return.

Parameters
replyData

The reply data from the execute operation.

Since:

BlackBerry 10.0.0

Last modified: 2014-09-30



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus