UtiLite
0.3.1
A lite utilities library
|
#include <UObjDeletionThread.h>
Inherits UThread.
Public Member Functions | |
UObjDeletionThread (T *obj, int id=0) | |
virtual | ~UObjDeletionThread () |
void | startDeletion (int waitMs=0) |
int | id () const |
void | setObj (T *obj) |
Private Member Functions | |
virtual void | mainLoop () |
This class can be used to delete a dynamically created object in another thread. Give the dynamic reference to object to it and it will notify with a UObjDeletedEvent when the object is deleted. The deletion can be delayed on startDeletion(), the thread will wait the time given before deleting the object.
UObjDeletionThread< T >::UObjDeletionThread | ( | T * | obj, |
int | id = 0 |
||
) | [inline] |
The constructor.
obj | the object to delete |
id | the custom id which will be sent in a event UObjDeletedEvent after the object is deleted |
virtual UObjDeletionThread< T >::~UObjDeletionThread | ( | ) | [inline, virtual] |
The destructor. If this thread is not started but with an object set, the object is deleted. If the thread has not finished to delete the object, the calling thread will wait (on a UThreadNode::join()) until the object is deleted.
obj | the object to delete |
id | the custom id which will be sent in a event UObjDeletedEvent after the object is deleted |
int UObjDeletionThread< T >::id | ( | ) | const [inline] |
Get id of the deleted object.
virtual void UObjDeletionThread< T >::mainLoop | ( | ) | [inline, private, virtual] |
Thread main loop...
Implements UThread.
void UObjDeletionThread< T >::setObj | ( | T * | obj | ) | [inline] |
Set a new object, if one was already set, the old one is deleted.
obj | the object to delete |
void UObjDeletionThread< T >::startDeletion | ( | int | waitMs = 0 | ) | [inline] |
Start the thread after optional delay.
waitMs | the delay before deletion |