13 #ifndef PQXX_PIPELINE_HXX
14 #define PQXX_PIPELINE_HXX
16 #if !defined(PQXX_HEADER_PRE)
17 # error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
86 query_id insert(std::string_view,
sl =
sl::current()) &;
95 void complete(
sl =
sl::current());
107 void flush(
sl =
sl::current());
118 void cancel(
sl =
sl::current());
121 [[nodiscard]]
bool is_finished(query_id) const;
132 return retrieve(m_queries.find(qid), loc).second;
137 std::pair<query_id, result> retrieve(
sl = sl::current());
139 [[nodiscard]]
bool empty() const noexcept {
return std::empty(m_queries); }
153 int retain(
int retain_max = 2) &;
156 void resume(
sl loc = sl::current()) &;
161 explicit Query(std::string_view q) :
162 query{std::make_shared<std::string>(q)}
166 std::shared_ptr<std::string> query;
171 using QueryMap = std::map<query_id, Query>;
178 static constexpr query_id qid_limit() noexcept
184 return (std::numeric_limits<query_id>::max)();
190 [[nodiscard]]
bool have_pending() const noexcept
192 return m_issuedrange.second != m_issuedrange.first;
198 void set_error_at(query_id qid) noexcept
200 if (qid < m_error) [[unlikely]]
205 [[noreturn]]
PQXX_PRIVATE void internal_error(std::string
const &err,
sl);
217 PQXX_PRIVATE void receive(pipeline::QueryMap::const_iterator stop,
sl);
218 std::pair<pipeline::query_id, result>
219 retrieve(pipeline::QueryMap::iterator,
sl);
222 std::pair<QueryMap::iterator, QueryMap::iterator> m_issuedrange;
224 int m_num_waiting = 0;
228 bool m_dummy_pending =
false;
231 query_id m_error = qid_limit();
242 static constexpr std::string_view s_classname{
"pipeline"};
Processes several queries in FIFO manner, optimized for high throughput.
Definition: pipeline.hxx:51
bool empty() const noexcept
Definition: pipeline.hxx:139
pipeline(transaction_base &t, std::string_view tname, sl loc=sl::current())
Start a pipeline. Assign it a name, for more helpful error messages.
Definition: pipeline.hxx:69
pipeline(transaction_base &t, sl loc=sl::current())
Start a pipeline.
Definition: pipeline.hxx:63
pipeline(pipeline &&)=delete
pipeline(pipeline const &)=delete
long query_id
Identifying numbers for queries.
Definition: pipeline.hxx:54
pipeline & operator=(pipeline &&)=delete
pipeline & operator=(pipeline const &)=delete
Result set containing data returned by a query or command.
Definition: result.hxx:101
Base class for things that monopolise a transaction's attention.
Definition: transaction_focus.hxx:29
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:151
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
encoding_group
Definition: encoding_group.hxx:40
@ unknown
Default: indeterminate encoding. All we know is it supports ASCII.