28 for (std::size_t i = 0; i !=
sessions_.size(); ++i)
55 for (std::size_t i = 0; i != size; ++i)
60 int cc = pthread_mutex_init(&(
pimpl_->
mtx_), NULL);
119 gettimeofday(&tmv, NULL);
121 tm.tv_sec = tmv.tv_sec + timeout / 1000;
122 tm.tv_nsec = tmv.tv_usec * 1000 + (timeout % 1000) * 1000 * 1000;
124 if (tm.tv_nsec >= 1000 * 1000 * 1000)
127 tm.tv_nsec -= 1000 * 1000 * 1000;
147 cc = pthread_cond_timedwait(
183 throw soci_error(
"Cannot release pool entry (already free)");
198 using namespace soci;
204 for (std::size_t i = 0; i !=
sessions_.size(); ++i)
217 std::vector<std::pair<bool, session *> >
sessions_;
219 CRITICAL_SECTION
mtx_;
232 for (std::size_t i = 0; i != size; ++i)
240 HANDLE s = CreateSemaphore(NULL,
241 static_cast<LONG>(size), static_cast<LONG>(size), NULL);
258 CloseHandle(
pimpl_->sem_);
290 DWORD cc = WaitForSingleObject(
pimpl_->sem_,
291 timeout >= 0 ? static_cast<DWORD>(timeout) : INFINITE);
292 if (cc == WAIT_OBJECT_0)
311 else if (cc == WAIT_TIMEOUT)
333 throw soci_error(
"Cannot release pool entry (already free)");
340 ReleaseSemaphore(
pimpl_->sem_, 1, NULL);
bool try_lease(std::size_t &pos, int timeout)
void give_back(std::size_t pos)
std::vector< std::pair< bool, session * > > sessions_
session & at(std::size_t pos)
connection_pool_impl * pimpl_
bool find_free(std::size_t &pos)
connection_pool(std::size_t size)