Classes | |
| class | CASGarbage |
| Implements a simple garbage collection. More... | |
| class | CASGarbageSort_Cmp |
| Sorts a vector or list by the memory address of the elements. More... | |
Functions | |
| CASGarbage::CASGarbage (const CASGarbage &wdc) | |
| Copy constructor. | |
| CASGarbage::CASGarbage () | |
| Constructor. | |
| void * | CASGarbage_thread_wrapper (void *object) |
Wrapper function for pthread_create(). | |
| void | CASGarbage::CheckRetVal (int rv, std::string fname) |
| Throws an exception according to the return value. | |
| void | CASGarbage::CreateTrasherThread () |
| Creates the trasher thread. | |
| CASGarbage & | CASGarbage::operator= (const CASGarbage &wdc) |
| Assignment operator. | |
| void | CASGarbage::Put (const std::list< CASObject * > &l) |
Adds the CASObject listed in a list to the garbage. | |
| void | CASGarbage::Put (const std::vector< CASObject * > &v) |
Adds the CASObject listed in a vector to the garbage. | |
| void | CASGarbage::Put (CASObject *o) |
Adds a single object CASObject to the garbage. | |
| void | CASGarbage::RemoveDuplicate () |
| Removes duplicate object addresses from the garbage vector. | |
| void | CASGarbage::TerminateTrasherThread () |
| Signals the termination of the thread. | |
| void * | CASGarbage::Trasher () |
| The function which is called from the thread wrapper function. | |
| CASGarbage::~CASGarbage () | |
| Destructor. | |
| CASGarbage::CASGarbage | ( | const CASGarbage & | wdc | ) | [inherited] |
Copy constructor. Does throw a EDoesNotApply exception.
| wdc | We don't care. |
Definition at line 267 of file casgarbage.cc.
| CASGarbage::CASGarbage | ( | ) | [inherited] |
Constructor. Initializes all attributes and sets up the mutex.
Definition at line 202 of file casgarbage.cc.
| void* CASGarbage_thread_wrapper | ( | void * | object | ) |
This function is passed as argument to the pthread_create() function. Its solely purpose is to call CASGarbage::Trasher() which then takes over control.
| object | Void pointer to the CASGarbage object. |
CASGarbage::Trasher() returns. Definition at line 64 of file casgarbage.cc.
| void CASGarbage::CheckRetVal | ( | int | rv, | |
| std::string | fname | |||
| ) | [private, inherited] |
CheckRetVal() is used to check the return value of the various pthread_* functions
If the return value is not equal to 0 ('zero'), it throws an appropriate exception and puts the name of the failing function into the msg string of the exception object.
| rv | int representing the return value of the function. | |
| fname | String holding the function name of the function failing. |
Definition at line 168 of file casgarbage.cc.
| void CASGarbage::CreateTrasherThread | ( | ) | [private, inherited] |
Creates the 'Trasher Thread'. It checks the attribute trasher_thread_created, whether or not a thread has already been created. If no thread has been created so far, it creates a new thread and sets the trasher_thread_created attribute to true. Therefore it is save to call this function multiple times without creating multiple threads.
Definition at line 83 of file casgarbage.cc.
| CASGarbage & CASGarbage::operator= | ( | const CASGarbage & | wdc | ) | [inherited] |
Assignment operator. Just for completness. It does always throw an EDoesNotApply() exception when called.
| wdc | We don't care. |
EDoesNotApply() exception. Definition at line 421 of file casgarbage.cc.
| void CASGarbage::Put | ( | const std::list< CASObject * > & | l | ) | [inherited] |
This function adds the objects listed in a list to the garbage list and calls the method CASGarbage::CreateTrasherThread() which creates a thread that takes care of the garbage.
| &l | A reference to a list holding the addresses of the objects. |
Definition at line 386 of file casgarbage.cc.
| void CASGarbage::Put | ( | const std::vector< CASObject * > & | v | ) | [inherited] |
This function adds the objects listed in a vector to the garbage list and calls the method CASGarbage::CreateTrasherThread() which creates a thread that takes care of the garbage.
| &v | A reference to a vector holding the addresses of the objects. |
Definition at line 354 of file casgarbage.cc.
| void CASGarbage::Put | ( | CASObject * | o | ) | [inherited] |
This function adds a single object to the garbage list and calls the method CASGarbage::CreateTrasherThread() which creates a thread that takes care of the garbage.
| o | Pointer to a CASObject. |
Definition at line 325 of file casgarbage.cc.
| void CASGarbage::RemoveDuplicate | ( | ) | [private, inherited] |
This function removes duplicate objects from the list. It does this by comparing the memory addresses of the objects.
Definition at line 140 of file casgarbage.cc.
| void CASGarbage::TerminateTrasherThread | ( | ) | [private, inherited] |
It waits for the Trasher Thread to finish. However, if no thread has been created, it immediately returns.
Definition at line 107 of file casgarbage.cc.
| void * CASGarbage::Trasher | ( | ) | [inherited] |
The thread function which spends its entire life in a loop. Befor entering the loop, it locks the mutex. The mutex will be explicitly unlocked by calling pthread_mutex_unlock() when the thread is signalled to terminate. Inside the loop, the mutex is implicitly unlocked by calling pthread_cond_wait(). Thus, the thread waits for CASGarbage::Put() to signal something was put on the garbage. However, the thread starts to delete objects from memory only when the vector holding the objects reaches a certain threshold of size.
Definition at line 290 of file casgarbage.cc.
| CASGarbage::~CASGarbage | ( | ) | [inherited] |
Destructor. Terminates the thread, destroys all remaining objects in the list vector, and destroys the mutex.
Definition at line 233 of file casgarbage.cc.
1.4.7