libmoost
|
a resource_stack is a thread-safe collection of resources. Threads can get resources from the stack by using a scoped_resource. More...
#include <resource_stack.hpp>
Classes | |
class | scoped_resource |
Use a scoped_resource to get a resource from the resource_stack. More... | |
Public Types | |
typedef T | resource_type |
Public Member Functions | |
resource_stack () | |
Constructs a resource. | |
resource_stack (const std::string &resource_name) | |
void | set_resource_name (const std::string &resource_name) |
Sets the name of the resource. | |
deprecated__ void | add_resource (T *presource) |
void | add_resource (boost::shared_ptr< T > spresource) |
size_t | size () |
size_t | total_size () |
Gets the total size of the resource stack (the number of resources added via add_resource) | |
Private Attributes | |
std::stack< boost::shared_ptr < T > > | m_resources |
boost::mutex | m_mutex |
boost::condition | m_cond |
size_t | m_total_size |
std::string | m_resource_name |
a resource_stack is a thread-safe collection of resources. Threads can get resources from the stack by using a scoped_resource.
Definition at line 53 of file resource_stack.hpp.
typedef T moost::container::resource_stack< T >::resource_type |
Definition at line 65 of file resource_stack.hpp.
moost::container::resource_stack< T >::resource_stack | ( | ) |
Constructs a resource.
Definition at line 108 of file resource_stack.hpp.
moost::container::resource_stack< T >::resource_stack | ( | const std::string & | resource_name | ) |
Definition at line 121 of file resource_stack.hpp.
void moost::container::resource_stack< T >::add_resource | ( | T * | presource | ) |
Adds a resource to the stack. IMPORTANT: this will take the ownership of the pointer!!
Definition at line 130 of file resource_stack.hpp.
void moost::container::resource_stack< T >::add_resource | ( | boost::shared_ptr< T > | spresource | ) |
Definition at line 140 of file resource_stack.hpp.
void moost::container::resource_stack< T >::set_resource_name | ( | const std::string & | resource_name | ) | [inline] |
Sets the name of the resource.
Definition at line 88 of file resource_stack.hpp.
size_t moost::container::resource_stack< T >::size | ( | ) |
Gets the size of the resource stack Note that this returns the number of available resources, not the total number of resources ever added.
Definition at line 149 of file resource_stack.hpp.
size_t moost::container::resource_stack< T >::total_size | ( | ) |
Gets the total size of the resource stack (the number of resources added via add_resource)
Definition at line 156 of file resource_stack.hpp.
boost::condition moost::container::resource_stack< T >::m_cond [private] |
Definition at line 59 of file resource_stack.hpp.
boost::mutex moost::container::resource_stack< T >::m_mutex [private] |
Definition at line 58 of file resource_stack.hpp.
std::string moost::container::resource_stack< T >::m_resource_name [private] |
Definition at line 61 of file resource_stack.hpp.
std::stack< boost::shared_ptr<T> > moost::container::resource_stack< T >::m_resources [private] |
Definition at line 57 of file resource_stack.hpp.
size_t moost::container::resource_stack< T >::m_total_size [private] |
Definition at line 60 of file resource_stack.hpp.