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
51 namedclass{
"pipeline"}, transactionfocus{t}
56 namedclass{
"pipeline", name}, transactionfocus{t}
61 namedclass{
"pipeline", std::move(name)}, transactionfocus{t}
66 namedclass{
"pipeline", name}, transactionfocus{t}
80 query_id insert(std::string_view);
115 [[nodiscard]]
bool is_finished(query_id) const;
126 return retrieve(m_queries.find(qid)).second;
131 std::pair<query_id, result> retrieve();
133 [[nodiscard]]
bool empty() const noexcept {
return m_queries.empty(); }
148 int retain(
int retain_max = 2);
155 struct PQXX_PRIVATE Query
157 explicit Query(std::string_view q) :
158 query{std::make_shared<std::string>(q)}
161 std::shared_ptr<std::string> query;
165 using QueryMap = std::map<query_id, Query>;
172 static constexpr query_id qid_limit() noexcept
178 return (std::numeric_limits<query_id>::max)();
182 PQXX_PRIVATE query_id generate_id();
184 bool have_pending() const noexcept
186 return m_issuedrange.second != m_issuedrange.first;
189 PQXX_PRIVATE
void issue();
192 void set_error_at(query_id qid) noexcept
199 [[noreturn]] PQXX_PRIVATE
void internal_error(std::string
const &err);
201 PQXX_PRIVATE
bool obtain_result(
bool expect_none =
false);
203 PQXX_PRIVATE
void obtain_dummy();
204 PQXX_PRIVATE
void get_further_available_results();
205 PQXX_PRIVATE
void check_end_results();
208 PQXX_PRIVATE
void receive_if_available();
211 PQXX_PRIVATE
void receive(pipeline::QueryMap::const_iterator stop);
212 std::pair<pipeline::query_id, result> retrieve(pipeline::QueryMap::iterator);
215 std::pair<QueryMap::iterator, QueryMap::iterator> m_issuedrange;
217 int m_num_waiting = 0;
221 bool m_dummy_pending =
false;
224 query_id m_error = qid_limit();
230 internal::encoding_group m_encoding;
234 #include "pqxx/internal/compiler-internal-post.hxx"
~pipeline() noexcept
Definition: pipeline.cxx:40
long query_id
Definition: pipeline.hxx:45
bool is_finished(query_id) const
Is result for given query available?
Definition: pipeline.cxx:132
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:26
void cancel()
Cancel ongoing query, if any.
Definition: pipeline.cxx:120
pipeline(pipeline const &)=delete
std::string to_string(field const &value)
Convert a field to a string.
Definition: result.cxx:498
encoding_group enc_group(int libpq_enc_id)
Definition: encodings.cxx:585
int retain(int retain_max=2)
Definition: pipeline.cxx:150
Processes several queries in FIFO manner, optimized for high throughput.
Definition: pipeline.hxx:43
std::pair< query_id, result > retrieve()
Retrieve oldest unretrieved result (possibly wait for one).
Definition: pipeline.cxx:142
Result set containing data returned by a query or command.
Definition: result.hxx:71
pipeline & operator=(pipeline const &)=delete
pipeline(transaction_base &t, char const name[])
Definition: pipeline.hxx:55
bool empty() const noexcept
Definition: pipeline.hxx:133
Something is out of range, similar to std::out_of_range.
Definition: except.hxx:194
pipeline(transaction_base &t)
Definition: pipeline.hxx:50
Internal error in libpqxx library.
Definition: except.hxx:159
void resume()
Resume retained query emission. Harmless when not needed.
Definition: pipeline.cxx:166
void flush()
Forget all ongoing or pending operations and retrieved results.
Definition: pipeline.cxx:105
pipeline(transaction_base &t, std::string &&name)
Definition: pipeline.hxx:60
query_id insert(std::string_view)
Add query to the pipeline.
Definition: pipeline.cxx:66
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
pipeline(transaction_base &t, std::string_view name)
Definition: pipeline.hxx:65
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:69
void complete()
Wait for all ongoing or pending operations to complete, and detach.
Definition: pipeline.cxx:92