11 #ifndef PQXX_TRANSACTOR_HXX
12 #define PQXX_TRANSACTOR_HXX
14 #if !defined(PQXX_HEADER_PRE)
15 # error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
19 #include <type_traits>
101 template<
typename TRANSACTION_CALLBACK>
102 inline std::invoke_result_t<TRANSACTION_CALLBACK>
perform(
103 TRANSACTION_CALLBACK &&callback,
int attempts = 3,
sl loc = sl::current())
106 throw std::invalid_argument{
107 "Zero or negative number of attempts passed to pqxx::perform()."};
109 for (; attempts > 0; --attempts)
113 return std::invoke(callback);
145 throw internal_error{
"Reached unreachable transactor state.", loc};
149 template<
typename TRANSACTION_CALLBACK>
150 [[deprecated(
"No soruce_location needed.")]]
inline std::invoke_result_t<
151 TRANSACTION_CALLBACK>
154 return perform(std::forward(callback), 3, loc);
Base type for all exceptions specific to libpqxx.
Definition: except.hxx:76
"Help, I don't know whether transaction was committed successfully!"
Definition: except.hxx:451
Resource shortage on the server.
Definition: except.hxx:919
Internal error in libpqxx library.
Definition: except.hxx:558
We can't tell whether our last statement succeeded.
Definition: except.hxx:524
Definition: except.hxx:958
The home of all libpqxx classes, functions, templates, etc.
Definition: array.cxx:26
std::source_location sl
Convenience alias for std::source_location. It's just too long.
Definition: types.hxx:38
std::invoke_result_t< TRANSACTION_CALLBACK > perform(TRANSACTION_CALLBACK &&callback, int attempts=3, sl loc=sl::current())
Simple way to execute a transaction with automatic retry.
Definition: transactor.hxx:102