added sqlite db backend progress
This commit is contained in:
@@ -40,10 +40,11 @@ template < class Connection >
|
||||
class connection_pool
|
||||
{
|
||||
public:
|
||||
connection_pool(const std::string &db, unsigned int count) {
|
||||
connection_pool(const std::string &dns, unsigned int count)
|
||||
: info_(connection_info::parse(dns)) {
|
||||
connection_repo_.reserve(count);
|
||||
for (auto i = 0U; i < count; ++i) {
|
||||
connection_repo_.emplace_back(db + std::to_string(i+1));
|
||||
connection_repo_.emplace_back(info_);
|
||||
idle_connections_.push(&connection_repo_.back());
|
||||
idle_connections_.back()->open();
|
||||
}
|
||||
@@ -87,6 +88,9 @@ public:
|
||||
return inuse_connections_.size();
|
||||
}
|
||||
|
||||
const connection_info &info() const {
|
||||
return info_;
|
||||
}
|
||||
private:
|
||||
mutable std::mutex mutex_;
|
||||
std::vector<Connection> connection_repo_;
|
||||
@@ -95,6 +99,8 @@ private:
|
||||
using connection_set = std::unordered_set<pointer>;
|
||||
connections idle_connections_;
|
||||
connection_set inuse_connections_;
|
||||
|
||||
const connection_info info_;
|
||||
};
|
||||
|
||||
template<class Connection>
|
||||
|
||||
Reference in New Issue
Block a user