18template <
typename R,
typename F>
19concept WithTxFn = std::is_invocable_r_v<R, F, pqxx::work &>;
25 explicit Pqxx(
const Loop &loop, std::string connectionString)
34 template <
typename R,
typename F>
48template <
typename R,
typename F>
56 auto work = [threadLocalConn = std::move(threadLocalConn),
57 connectionString = std::move(connectionString),
58 f = std::forward<F>(f)]()
mutable -> R {
60 if (!maybeConnection.has_value()) {
61 maybeConnection = std::make_optional(pqxx::connection{connectionString});
63 pqxx::work tx{maybeConnection.value()};
64 if constexpr (std::is_void_v<R>) {
75 return submitWork<R>(
loop_, work);
ThreadLocalKey< std::optional< pqxx::connection > > conn_
Definition pqxx.h:44
Pqxx(const Loop &loop, std::string connectionString)
Definition pqxx.h:25
const Loop & loop_
Definition pqxx.h:43
std::string connectionString_
Definition pqxx.h:45
void close()
Definition pqxx.h:40
Definition async_work.h:53
void del()
Definition async_work.h:64
T & getOrDefault()
Get the stored value, or create a new one if none exists.
Definition async_work.h:73
Promise< R > withTx(F f)
Definition pqxx.h:50
Definition async_work.cc:17