13 #ifndef PQXX_H_PIPELINE
14 #define PQXX_H_PIPELINE
20 #include "pqxx/transaction_base.hxx"
77 query_id insert(std::string_view) &;
112 [[nodiscard]]
bool is_finished(query_id) const;
123 return retrieve(m_queries.find(qid)).second;
128 std::pair<query_id, result> retrieve();
130 [[nodiscard]]
bool empty() const noexcept {
return std::empty(m_queries); }
145 int retain(
int retain_max = 2) &;
152 struct PQXX_PRIVATE Query
154 explicit Query(std::string_view q) :
155 query{std::make_shared<std::string>(q)}
158 std::shared_ptr<std::string> query;
162 using QueryMap = std::map<query_id, Query>;
169 static constexpr query_id qid_limit() noexcept
175 return (std::numeric_limits<query_id>::max)();
179 PQXX_PRIVATE query_id generate_id();
181 bool have_pending() const noexcept
183 return m_issuedrange.second != m_issuedrange.first;
186 PQXX_PRIVATE
void issue();
189 void set_error_at(query_id qid) noexcept
197 [[noreturn]] PQXX_PRIVATE
void internal_error(std::string
const &err);
199 PQXX_PRIVATE
bool obtain_result(
bool expect_none =
false);
201 PQXX_PRIVATE
void obtain_dummy();
202 PQXX_PRIVATE
void get_further_available_results();
203 PQXX_PRIVATE
void check_end_results();
206 PQXX_PRIVATE
void receive_if_available();
209 PQXX_PRIVATE
void receive(pipeline::QueryMap::const_iterator stop);
210 std::pair<pipeline::query_id, result> retrieve(pipeline::QueryMap::iterator);
213 std::pair<QueryMap::iterator, QueryMap::iterator> m_issuedrange;
215 int m_num_waiting = 0;
219 bool m_dummy_pending =
false;
222 query_id m_error = qid_limit();
228 internal::encoding_group m_encoding;
231 constexpr
static std::string_view s_classname{
"pipeline"};
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:23
Processes several queries in FIFO manner, optimized for high throughput.
Definition: pipeline.hxx:47
pipeline(transaction_base &t)
Start a pipeline.
Definition: pipeline.hxx:56
bool empty() const noexcept
Definition: pipeline.hxx:130
pipeline(transaction_base &t, std::string_view tname)
Start a pipeline. Assign it a name, for more helpful error messages.
Definition: pipeline.hxx:61
pipeline(pipeline const &)=delete
long query_id
Identifying numbers for queries.
Definition: pipeline.hxx:50
pipeline & operator=(pipeline const &)=delete
Result set containing data returned by a query or command.
Definition: result.hxx:68
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:73
Base class for things that monopolise a transaction's attention.
Definition: transaction_focus.hxx:25