libqi-api  2.0.6.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Member Functions
qi::Trackable< T > Class Template Reference

#include <trackable.hpp>

List of all members.

Public Member Functions

 Trackable (T *ptr)
 ~Trackable ()
boost::shared_ptr< T > lock ()
boost::weak_ptr< T > weakPtr ()
void wait ()

Protected Member Functions

void destroy ()

Detailed Description

template<typename T>
class qi::Trackable< T >

Object tracking by blocking destruction while shared pointers are present.

Inherit from Trackable to allow a form of tracking that blocks destruction while shared pointers are held. This allows using your class without a shared_ptr wrapper.

Warning:
when inheriting from this class, you *must* invoke the destroy() method from your destructor, before any operation that puts your object in an invalid state.
since destroy() blocks until all shared pointers are destroyed, deadlocks may occur if used improperly.

Definition at line 40 of file trackable.hpp.


Constructor & Destructor Documentation

template<typename T >
qi::Trackable< T >::Trackable ( T *  ptr) [inline]

Definition at line 21 of file trackable.hxx.

template<typename T >
qi::Trackable< T >::~Trackable ( ) [inline]

Definition at line 54 of file trackable.hxx.


Member Function Documentation

template<typename T >
void qi::Trackable< T >::destroy ( ) [inline, protected]

*Must* be called by parent class destructor, first thing. Can block until lock holders terminate

Definition at line 28 of file trackable.hxx.

template<typename T >
boost::shared_ptr< T > qi::Trackable< T >::lock ( ) [inline]
Returns:
a shared_ptr that will block destruction (call to destroy() until it is released, or an empty shared_ptr if destroy was already called.

Definition at line 67 of file trackable.hxx.

template<typename T >
void qi::Trackable< T >::wait ( ) [inline]

Blocks until destroy() is called and all shared_ptr built from weak_ptr() are deleted.

Definition at line 35 of file trackable.hxx.

template<typename T >
boost::weak_ptr< T > qi::Trackable< T >::weakPtr ( ) [inline]
Returns:
a weak_ptr from this. While a shared_ptr exists from this weak_ptr, a call to destroy will block()

Definition at line 73 of file trackable.hxx.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines