cumbia 1.x
general purpose multi threaded library
Loading...
Searching...
No Matches
CuThreadListener Class Referenceabstract

interface for a listener that is notified when progress is done in the background and data is ready More...

#include <cuthreadlistener.h>

Public Member Functions

virtual ~CuThreadListener ()
 
virtual void onProgress (int step, int total, const CuData &data)=0
 onProgress notifies the listener's thread about the progress of the ongoing work in the activity's background thread More...
 
virtual void onResult (const CuData &data)=0
 onResult delivers to the listener's thread the results of the work performed by the activity's background thread More...
 
virtual void onResult (const std::vector< CuData > &datalist)=0
 onResult delivers to the listener's thread the results of the work performed by the activity's background thread More...
 
virtual void onResult (const CuUserData *u)
 custom user-data flavor of the above More...
 
virtual CuData getToken () const =0
 getToken returns a token characterizing the listener More...
 

Detailed Description

interface for a listener that is notified when progress is done in the background and data is ready

Listeners will implement three methods, that are callbacks used to deliver data from the background activity thread to the listener's thread (in graphical applications often called the gui thread or main thread):

  • onProgress: callback that delivers to the listener's thread progress information on the ongoing background operation in the CuActivity. Triggered by CuActivity::publishProgress
  • onResult: callback that delivers results to the listener's thread from the background operation in the CuActivity. Triggered by CuActivity::publishResult
  • getToken returns a descriptive token used to characterize the listener

Thread listeners are registered to the Cumbia engine in conjunction with the associated CuActivity through the method Cumbia::registerActivity.

Please see the md_src_tutorial_cuactivity documentation for an example.

See also
CuActivity

Constructor & Destructor Documentation

◆ ~CuThreadListener()

virtual CuThreadListener::~CuThreadListener ( )
inlinevirtual

Member Function Documentation

◆ getToken()

virtual CuData CuThreadListener::getToken ( ) const
pure virtual

getToken returns a token characterizing the listener

Returns
a CuData with key/value pairs describing the listener.

◆ onProgress()

virtual void CuThreadListener::onProgress ( int  step,
int  total,
const CuData data 
)
pure virtual

onProgress notifies the listener's thread about the progress of the ongoing work in the activity's background thread

Parameters
stepthe current step
totalthe total number of steps
dataCuData bundle storing (partial) results

◆ onResult() [1/3]

virtual void CuThreadListener::onResult ( const CuData data)
pure virtual

onResult delivers to the listener's thread the results of the work performed by the activity's background thread

Parameters
dataCuData bundle storing the results computed in the background activity

◆ onResult() [2/3]

virtual void CuThreadListener::onResult ( const CuUserData u)
inlinevirtual

custom user-data flavor of the above

Parameters
pointerto user defined CuUserData data
Note
This method does nothing by default and does not need to be implemented by subclasses

◆ onResult() [3/3]

virtual void CuThreadListener::onResult ( const std::vector< CuData > &  datalist)
pure virtual

onResult delivers to the listener's thread the results of the work performed by the activity's background thread

Parameters
datalista std::vector of CuData bundle storing a list of results computed in the background activity

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