13 #ifndef PQXX_H_PIPELINE
14 #define PQXX_H_PIPELINE
16 #include "pqxx/compiler-public.hxx"
17 #include "pqxx/internal/compiler-internal-pre.hxx"
23 #include "pqxx/transaction_base.hxx"
42 class PQXX_LIBEXPORT
pipeline :
public internal::transactionfocus
55 transactionfocus{t, s_classname, tname}
69 query_id insert(std::string_view);
104 [[nodiscard]]
bool is_finished(query_id) const;
115 return retrieve(m_queries.find(qid)).second;
120 std::pair<query_id, result> retrieve();
122 [[nodiscard]]
bool empty() const noexcept {
return std::empty(m_queries); }
137 int retain(
int retain_max = 2);
144 struct PQXX_PRIVATE Query
146 explicit Query(std::string_view q) :
147 query{std::make_shared<std::string>(q)}
150 std::shared_ptr<std::string> query;
154 using QueryMap = std::map<query_id, Query>;
161 static constexpr query_id qid_limit() noexcept
167 return (std::numeric_limits<query_id>::max)();
171 PQXX_PRIVATE query_id generate_id();
173 bool have_pending() const noexcept
175 return m_issuedrange.second != m_issuedrange.first;
178 PQXX_PRIVATE
void issue();
181 void set_error_at(query_id qid) noexcept
188 [[noreturn]] PQXX_PRIVATE
void internal_error(std::string
const &err);
190 PQXX_PRIVATE
bool obtain_result(
bool expect_none =
false);
192 PQXX_PRIVATE
void obtain_dummy();
193 PQXX_PRIVATE
void get_further_available_results();
194 PQXX_PRIVATE
void check_end_results();
197 PQXX_PRIVATE
void receive_if_available();
200 PQXX_PRIVATE
void receive(pipeline::QueryMap::const_iterator stop);
201 std::pair<pipeline::query_id, result> retrieve(pipeline::QueryMap::iterator);
204 std::pair<QueryMap::iterator, QueryMap::iterator> m_issuedrange;
206 int m_num_waiting = 0;
210 bool m_dummy_pending =
false;
213 query_id m_error = qid_limit();
219 internal::encoding_group m_encoding;
221 constexpr
static std::string_view s_classname{
"pipeline"};
225 #include "pqxx/internal/compiler-internal-post.hxx"
pipeline(transaction_base &t)
Definition: pipeline.hxx:50
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:26
void resume()
Resume retained query emission. Harmless when not needed.
Definition: pipeline.cxx:168
encoding_group enc_group(int libpq_enc_id)
Definition: encodings.cxx:571
std::pair< query_id, result > retrieve()
Retrieve oldest unretrieved result (possibly wait for one).
Definition: pipeline.cxx:144
pipeline(transaction_base &t, std::string_view tname)
Definition: pipeline.hxx:54
query_id insert(std::string_view)
Add query to the pipeline.
Definition: pipeline.cxx:67
Something is out of range, similar to std::out_of_range.
Definition: except.hxx:193
pipeline(pipeline const &)=delete
Internal error in libpqxx library.
Definition: except.hxx:158
~pipeline() noexcept
Definition: pipeline.cxx:41
long query_id
Definition: pipeline.hxx:45
bool is_finished(query_id) const
Is result for given query available?
Definition: pipeline.cxx:133
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:72
void complete()
Wait for all ongoing or pending operations to complete, and detach.
Definition: pipeline.cxx:93
void flush()
Forget all ongoing or pending operations and retrieved results.
Definition: pipeline.cxx:106
int retain(int retain_max=2)
Definition: pipeline.cxx:152
std::string separated_list(std::string_view sep, ITER begin, ITER end, ACCESS access)
Represent sequence of values as a string, joined by a given separator.
Definition: separated_list.hxx:40
Processes several queries in FIFO manner, optimized for high throughput.
Definition: pipeline.hxx:43
pipeline & operator=(pipeline const &)=delete
bool empty() const noexcept
Definition: pipeline.hxx:122
Result set containing data returned by a query or command.
Definition: result.hxx:71
void cancel()
Cancel ongoing query, if any.
Definition: pipeline.cxx:121