# 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

Constructor.

AcquisitionProxy(const std::shared_ptr<TResource>& resource, const std::shared_ptr<PoolInstance>& pool)
  : _obj(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
[none] Pool Protected Constructor.
std::shared_ptr<Pool> createShared Create shared Pool.
std::shared_ptr<TResource> get Get resource.
async::CoroutineStarterForResult<const std::shared_ptr<TResource>&> getAsync Get resource asynchronously.
void invalidate Invalidate resource.
void stop Stop pool.
v_int64 getCounter Get pool resource count. Both acquired and available.

# Pool::Pool

Protected Constructor.

  • @param provider
  • @param maxResources
  • @param maxResourceTTL

Pool(const std::shared_ptr<TProvider>& provider, v_int64 maxResources, v_int64 maxResourceTTL)
  : PoolTemplate<TResource, AcquisitionProxyImpl>(provider, maxResources, maxResourceTTL)

# 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.
  • @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)

# Pool::get

Get resource.

  • @return

std::shared_ptr<TResource> get() override

# Pool::getAsync

Get resource asynchronously.

  • @return

async::CoroutineStarterForResult<const std::shared_ptr<TResource>&> getAsync() override

# Pool::invalidate

Invalidate resource.

  • @param resource

void invalidate(const std::shared_ptr<TResource>& resource) 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()