mirror of
https://github.com/SOCI/soci.git
synced 2025-12-21 13:00:23 -06:00
Use unique_ptr<> for connection_pool::pimpl_
Also don't duplicate connection_pool ctor and dtor in POSIX and Windows branches as they are exactly the same for both of them. No real changes.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "soci/soci-platform.h"
|
||||
// std
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
|
||||
namespace soci
|
||||
{
|
||||
@@ -31,7 +32,7 @@ public:
|
||||
|
||||
private:
|
||||
struct connection_pool_impl;
|
||||
connection_pool_impl * pimpl_;
|
||||
std::unique_ptr<connection_pool_impl> pimpl_;
|
||||
|
||||
SOCI_NOT_COPYABLE(connection_pool)
|
||||
};
|
||||
|
||||
@@ -98,16 +98,6 @@ struct connection_pool::connection_pool_impl : connection_pool_base_impl
|
||||
pthread_cond_t cond_;
|
||||
};
|
||||
|
||||
connection_pool::connection_pool(std::size_t size)
|
||||
{
|
||||
pimpl_ = new connection_pool_impl(size);
|
||||
}
|
||||
|
||||
connection_pool::~connection_pool()
|
||||
{
|
||||
delete pimpl_;
|
||||
}
|
||||
|
||||
bool connection_pool::try_lease(std::size_t & pos, int timeout)
|
||||
{
|
||||
struct timespec tm;
|
||||
@@ -242,16 +232,6 @@ struct connection_pool::connection_pool_impl : connection_pool_base_impl
|
||||
HANDLE sem_;
|
||||
};
|
||||
|
||||
connection_pool::connection_pool(std::size_t size)
|
||||
{
|
||||
pimpl_ = new connection_pool_impl(size);
|
||||
}
|
||||
|
||||
connection_pool::~connection_pool()
|
||||
{
|
||||
delete pimpl_;
|
||||
}
|
||||
|
||||
bool connection_pool::try_lease(std::size_t & pos, int timeout)
|
||||
{
|
||||
DWORD cc = WaitForSingleObject(pimpl_->sem_,
|
||||
@@ -308,6 +288,13 @@ void connection_pool::give_back(std::size_t pos)
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
connection_pool::connection_pool(std::size_t size)
|
||||
: pimpl_(std::make_unique<connection_pool_impl>(size))
|
||||
{
|
||||
}
|
||||
|
||||
connection_pool::~connection_pool() = default;
|
||||
|
||||
session & connection_pool::at(std::size_t pos)
|
||||
{
|
||||
if (pos >= pimpl_->sessions_.size())
|
||||
|
||||
Reference in New Issue
Block a user