cumbia 1.x
general purpose multi threaded library
Loading...
Searching...
No Matches
CuActivityManager Class Reference

This service stores the links between threads, activities and thread listeners. More...

#include <cuactivitymanager.h>

Inheritance diagram for CuActivityManager:

Public Member Functions

 CuActivityManager ()
 The Cumbia Activity Manager keeps the links between threads, activities and thread listeners. CuActivityManager deals with adding, removing and finding objects connected with each other. More...
 
virtual ~CuActivityManager ()
 
void connect (CuThreadInterface *t, CuActivity *a, CuThreadListener *threadListener)
 
void disconnect (CuActivity *a)
 Removes all links where a is involved. More...
 
void removeConnections (CuThreadInterface *t)
 Removes all links involving the CuThreadInterface passed as input. More...
 
void disconnect (CuThreadListener *l)
 
CuActivityfind (const CuData &token)
 finds an activity matching the given token More...
 
CuThreadInterfacegetThread (CuActivity *activity)
 returns the CuThreadInterface that executes the given activity More...
 
bool isRegistered (const CuActivity *a)
 
std::vector< CuActivity * > activitiesForThread (const CuThreadInterface *ti)
 
int countActivitiesForThread (const CuThreadInterface *ti)
 
std::vector< CuThreadListener * > getThreadListeners (const CuActivity *activity)
 
bool connectionExists (CuThreadInterface *t, CuActivity *a, CuThreadListener *threadListener)
 
std::string getName () const
 return the name of the service More...
 
CuServices::Type getType () const
 return the type of the service More...
 
- Public Member Functions inherited from CuServiceI
virtual ~CuServiceI ()
 
virtual std::string getName () const =0
 return the name of the service More...
 
virtual CuServices::Type getType () const =0
 return the type of the service More...
 

Detailed Description

This service stores the links between threads, activities and thread listeners.

Note
The service must be created and its methods accessed from the main thread.

Constructor & Destructor Documentation

◆ CuActivityManager()

CuActivityManager::CuActivityManager ( )

The Cumbia Activity Manager keeps the links between threads, activities and thread listeners. CuActivityManager deals with adding, removing and finding objects connected with each other.

Thread safety.
All the methods in this class are thread safe and can be accessed from within any CuActivity or other thread.

References CuActivityManagerPrivate::mythread.

◆ ~CuActivityManager()

CuActivityManager::~CuActivityManager ( )
virtual

Member Function Documentation

◆ activitiesForThread()

std::vector< CuActivity * > CuActivityManager::activitiesForThread ( const CuThreadInterface ti)

◆ connect()

◆ connectionExists()

bool CuActivityManager::connectionExists ( CuThreadInterface t,
CuActivity a,
CuThreadListener threadListener 
)

◆ countActivitiesForThread()

int CuActivityManager::countActivitiesForThread ( const CuThreadInterface ti)

◆ disconnect() [1/2]

void CuActivityManager::disconnect ( CuActivity a)

Removes all links where a is involved.

Parameters
athe activity to be removed together with the thread and thread listner(s) it's linked with

This unbinds threads from activities and thread listeners (CuThreadListener) from activities (CuActivity).

See CuActivityManager::removeConnection

References CuActivityManagerPrivate::conn_mumap, CuActivityManagerPrivate::mythread, and CuActivityManagerPrivate::th_lis_mumap.

Referenced by Cumbia::finish(), and Cumbia::unregisterActivity().

◆ disconnect() [2/2]

void CuActivityManager::disconnect ( CuThreadListener l)

◆ find()

CuActivity * CuActivityManager::find ( const CuData token)

finds an activity matching the given token

Returns
an activity matching the given token or NULL if either no activity matches the token or the found activity is disposable (it cannot be reused)
Note
If an activity matches the given token but is marked as disposable, NULL is returned.
Disposable activities
Cumbia::unregisterActivity marks an activity disposable when it must be considered useless because on its way to destruction.

References CuActivityManagerPrivate::conn_mumap, and CuActivityManagerPrivate::mythread.

Referenced by Cumbia::findActivity().

◆ getName()

std::string CuActivityManager::getName ( ) const
virtual

return the name of the service

Returns
a std::string with the name of the service

Implements CuServiceI.

◆ getThread()

CuThreadInterface * CuActivityManager::getThread ( CuActivity activity)

returns the CuThreadInterface that executes the given activity

Parameters
activitya pointer to the CuActivity you want to get the thread it is run in
Returns
a pointer to the thread (CuThreadInterface) where the activity is run, or NULL if the activity is not found in the activity manager connections map

References CuActivityManagerPrivate::conn_mumap, and CuActivityManagerPrivate::mythread.

Referenced by Cumbia::pauseActivity(), Cumbia::postEvent(), Cumbia::resumeActivity(), Cumbia::setActivityPeriod(), and Cumbia::unregisterActivity().

◆ getThreadListeners()

std::vector< CuThreadListener * > CuActivityManager::getThreadListeners ( const CuActivity activity)

◆ getType()

CuServices::Type CuActivityManager::getType ( ) const
virtual

return the type of the service

Returns
a CuServices::Type defining the type of service

Implements CuServiceI.

References CuServices::ActivityManager.

◆ isRegistered()

bool CuActivityManager::isRegistered ( const CuActivity a)

◆ removeConnections()

void CuActivityManager::removeConnections ( CuThreadInterface t)

Removes all links involving the CuThreadInterface passed as input.

Parameters
tthe CuThreadInterface thread input argument

This method

  1. finds all the activities a linked to t;
  2. removes the thread listeners linked to a
  3. removes the links between a and t
See also
removeConnection

References CuActivityManagerPrivate::conn_mumap, CuActivityManagerPrivate::mythread, and CuActivityManagerPrivate::th_lis_mumap.


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