svcore
1.9
|
A very simple class that facilitates running things like plugins without locking, by collecting unwanted objects and deleting them after a delay so as to be sure nobody's in the middle of using them. More...
#include <Scavenger.h>
Public Member Functions | |
Scavenger (int sec=2, int defaultObjectListSize=200) | |
~Scavenger () | |
void | claim (T *t) |
Call from an RT thread etc., to pass ownership of t to us. More... | |
void | scavenge (bool clearNow=false) |
Call from a non-RT thread. More... | |
Protected Types | |
typedef std::pair< T *, time_t > | ObjectTimePair |
typedef std::vector< ObjectTimePair > | ObjectTimeList |
typedef std::list< T * > | ObjectList |
Protected Member Functions | |
void | pushExcess (T *) |
void | clearExcess (time_t) |
Protected Attributes | |
ObjectTimeList | m_objects |
time_t | m_sec |
ObjectList | m_excess |
time_t | m_lastExcess |
QMutex | m_excessMutex |
unsigned int | m_claimed |
unsigned int | m_scavenged |
Detailed Description
template<typename T>
class Scavenger< T >
A very simple class that facilitates running things like plugins without locking, by collecting unwanted objects and deleting them after a delay so as to be sure nobody's in the middle of using them.
Requires scavenge() to be called regularly from a non-RT thread.
This is currently not at all suitable for large numbers of objects – it's just a quick hack for use with things like plugins.
Definition at line 44 of file Scavenger.h.
Member Typedef Documentation
|
protected |
Definition at line 63 of file Scavenger.h.
|
protected |
Definition at line 64 of file Scavenger.h.
|
protected |
Definition at line 68 of file Scavenger.h.
Constructor & Destructor Documentation
Definition at line 96 of file Scavenger.h.
Definition at line 106 of file Scavenger.h.
References Scavenger< T >::clearExcess(), Scavenger< T >::m_claimed, Scavenger< T >::m_objects, and Scavenger< T >::m_scavenged.
Member Function Documentation
void Scavenger< T >::claim | ( | T * | t | ) |
Call from an RT thread etc., to pass ownership of t to us.
Only one thread should be calling this on any given scavenger.
Definition at line 125 of file Scavenger.h.
References Scavenger< T >::m_claimed, Scavenger< T >::m_objects, and Scavenger< T >::pushExcess().
Referenced by DSSIPluginInstance::initialiseGroupMembership().
void Scavenger< T >::scavenge | ( | bool | clearNow = false | ) |
Call from a non-RT thread.
Only one thread should be calling this on any given scavenger.
Definition at line 150 of file Scavenger.h.
References Scavenger< T >::clearExcess(), Scavenger< T >::m_claimed, Scavenger< T >::m_lastExcess, Scavenger< T >::m_objects, Scavenger< T >::m_scavenged, and Scavenger< T >::m_sec.
Referenced by DSSIPluginInstance::deactivate().
|
protected |
Definition at line 178 of file Scavenger.h.
References Scavenger< T >::m_excess, Scavenger< T >::m_excessMutex, and Scavenger< T >::m_lastExcess.
Referenced by Scavenger< T >::claim().
|
protected |
Definition at line 190 of file Scavenger.h.
References Scavenger< T >::m_excess, Scavenger< T >::m_excessMutex, and Scavenger< T >::m_lastExcess.
Referenced by Scavenger< T >::scavenge(), and Scavenger< T >::~Scavenger().
Member Data Documentation
|
protected |
Definition at line 65 of file Scavenger.h.
Referenced by Scavenger< T >::claim(), Scavenger< T >::scavenge(), and Scavenger< T >::~Scavenger().
|
protected |
Definition at line 66 of file Scavenger.h.
Referenced by Scavenger< T >::scavenge().
|
protected |
Definition at line 69 of file Scavenger.h.
Referenced by Scavenger< T >::clearExcess(), and Scavenger< T >::pushExcess().
|
protected |
Definition at line 70 of file Scavenger.h.
Referenced by Scavenger< T >::clearExcess(), Scavenger< T >::pushExcess(), and Scavenger< T >::scavenge().
|
protected |
Definition at line 71 of file Scavenger.h.
Referenced by Scavenger< T >::clearExcess(), and Scavenger< T >::pushExcess().
|
protected |
Definition at line 75 of file Scavenger.h.
Referenced by Scavenger< T >::claim(), Scavenger< T >::scavenge(), and Scavenger< T >::~Scavenger().
|
protected |
Definition at line 76 of file Scavenger.h.
Referenced by Scavenger< T >::scavenge(), and Scavenger< T >::~Scavenger().
The documentation for this class was generated from the following file:
Generated by 1.8.11