AWS SDK for C++  1.9.68
AWS SDK for C++
Public Member Functions | List of all members
Aws::Utils::ExclusiveOwnershipResourceManager< RESOURCE_TYPE > Class Template Reference

#include <ResourceManager.h>

Public Member Functions

 ExclusiveOwnershipResourceManager ()
 
RESOURCE_TYPE Acquire ()
 
bool HasResourcesAvailable ()
 
void Release (RESOURCE_TYPE resource)
 
void PutResource (RESOURCE_TYPE resource)
 
Aws::Vector< RESOURCE_TYPE > ShutdownAndWait (size_t resourceCount)
 

Detailed Description

template<typename RESOURCE_TYPE>
class Aws::Utils::ExclusiveOwnershipResourceManager< RESOURCE_TYPE >

Generic resource manager with Acquire/Release semantics. Acquire will block waiting on a an available resource. Release will cause one blocked acquisition to unblock.

You must call ShutdownAndWait() when finished with this container, this unblocks the listening thread and gives you a chance to clean up the resource if needed. After calling ShutdownAndWait(), you must not call Acquire any more.

Definition at line 26 of file ResourceManager.h.

Constructor & Destructor Documentation

◆ ExclusiveOwnershipResourceManager()

template<typename RESOURCE_TYPE >
Aws::Utils::ExclusiveOwnershipResourceManager< RESOURCE_TYPE >::ExclusiveOwnershipResourceManager ( )
inline

Definition at line 29 of file ResourceManager.h.

Member Function Documentation

◆ Acquire()

template<typename RESOURCE_TYPE >
RESOURCE_TYPE Aws::Utils::ExclusiveOwnershipResourceManager< RESOURCE_TYPE >::Acquire ( )
inline

Returns a resource with exclusive ownership. You must call Release on the resource when you are finished or other threads will block waiting to acquire it.

Returns
instance of RESOURCE_TYPE

Definition at line 37 of file ResourceManager.h.

◆ HasResourcesAvailable()

template<typename RESOURCE_TYPE >
bool Aws::Utils::ExclusiveOwnershipResourceManager< RESOURCE_TYPE >::HasResourcesAvailable ( )
inline

Returns whether or not resources are currently available for acquisition

Returns
true means that at this instant some resources are available (though another thread may grab them from under you), this is only a hint.

Definition at line 59 of file ResourceManager.h.

◆ PutResource()

template<typename RESOURCE_TYPE >
void Aws::Utils::ExclusiveOwnershipResourceManager< RESOURCE_TYPE >::PutResource ( RESOURCE_TYPE  resource)
inline

Does not block or even touch the semaphores. This is intended for setup only, do not use this after Acquire has been called for the first time.

Parameters
resourceresource to be managed.

Definition at line 83 of file ResourceManager.h.

◆ Release()

template<typename RESOURCE_TYPE >
void Aws::Utils::ExclusiveOwnershipResourceManager< RESOURCE_TYPE >::Release ( RESOURCE_TYPE  resource)
inline

Releases a resource back to the pool. This will unblock one waiting Acquire call if any are waiting.

Parameters
resourceresource to release back to the pool

Definition at line 70 of file ResourceManager.h.

◆ ShutdownAndWait()

template<typename RESOURCE_TYPE >
Aws::Vector<RESOURCE_TYPE> Aws::Utils::ExclusiveOwnershipResourceManager< RESOURCE_TYPE >::ShutdownAndWait ( size_t  resourceCount)
inline

Waits for all acquired resources to be released, then empties the queue. You must call ShutdownAndWait() when finished with this container, this unblocks the listening thread and gives you a chance to clean up the resource if needed. After calling ShutdownAndWait(), you must not call Acquire any more.

@params resourceCount the number of resources you've added to the resource manager.

Returns
the previously managed resources that are now available for cleanup.

Definition at line 97 of file ResourceManager.h.


The documentation for this class was generated from the following file: