# Pool.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/core/provider/Pool.hpp"

# AcquisitionProxy

Pool acquisition proxy template.

  • @tparam TResource - abstract resource interface type, Ex.: IOStream.
  • @tparam AcquisitionProxyImpl - implementation of proxy.

namespace oatpp { namespace provider { 
  template<class TResource, class AcquisitionProxyImpl>
  class AcquisitionProxy : public TResource {}

# Typedefs

Type Name Summary
PoolTemplate<TResource, AcquisitionProxyImpl> PoolInstance Convenience typedef for Pool.

# Methods

Return Type Name Summary
[none] AcquisitionProxy Constructor.
[none] ~AcquisitionProxy Virtual destructor.

# AcquisitionProxy::PoolInstance

Convenience typedef for Pool.

typedef PoolTemplate<TResource, AcquisitionProxyImpl> PoolInstance

# AcquisitionProxy::AcquisitionProxy


AcquisitionProxy(const provider::ResourceHandle<TResource>& resource, const std::shared_ptr<PoolInstance>& pool)
  : _handle(resource)
  , m_pool(pool)
  , m_valid(true)

# AcquisitionProxy::~AcquisitionProxy

Virtual destructor.

virtual ~AcquisitionProxy()

# Pool

Pool template class.

  • @tparam TProvider - base class for pool to inherit, ex.: ServerConnectionProvider.
  • @tparam TResource - abstract resource interface type, Ex.: IOStream. Must be the same as a return-type of Provider.
  • @tparam AcquisitionProxyImpl - implementation of AcquisitionProxy.

namespace oatpp { namespace provider { 
  template<class TProvider, class TResource, class AcquisitionProxyImpl>
  class Pool :
    public TProvider,
    public std::enable_shared_from_this<Pool<TProvider, TResource, AcquisitionProxyImpl>>,
    public PoolTemplate<TResource, AcquisitionProxyImpl> {}

# Methods

Return Type Name Summary
std::shared_ptr<Pool> createShared Create shared Pool.
provider::ResourceHandle<TResource> get Get resource.
async::CoroutineStarterForResult<const provider::ResourceHandle<TResource>&> getAsync Get resource asynchronously.
void stop Stop pool.
v_int64 getCounter Get pool resource count. Both acquired and available.

# Pool::createShared

Create shared Pool.

  • @param provider - resource provider.
  • @param maxResources - max resource count in the pool.
  • @param maxResourceTTL - max time-to-live for unused resource in the pool.
  • @param timeout - optional timeout on Pool::get() and Pool::getAsync() operations.
  • @return - std::shared_ptr of Pool.

static std::shared_ptr<Pool> createShared(const std::shared_ptr<TProvider>& provider,
                                          v_int64 maxResources,
                                          const std::chrono::duration<v_int64, std::micro>& maxResourceTTL,
                                          const std::chrono::duration<v_int64, std::micro>& timeout = std::chrono::microseconds::zero())

# Pool::get

Get resource.

  • @return

provider::ResourceHandle<TResource> get() override

# Pool::getAsync

Get resource asynchronously.

  • @return

async::CoroutineStarterForResult<const provider::ResourceHandle<TResource>&> getAsync() override

# Pool::stop

Stop pool.
Note: call to stop() may block.

void stop() override

# Pool::getCounter

Get pool resource count. Both acquired and available.

  • @return

v_int64 getCounter()