Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

pipeline.hxx

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  *   FILE
00004  *      pqxx/pipeline.hxx
00005  *
00006  *   DESCRIPTION
00007  *      definition of the pqxx::pipeline class.
00008  *   Throughput-optimized query manager
00009  *   DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/pipeline instead.
00010  *
00011  * Copyright (c) 2003-2004, Jeroen T. Vermeulen <jtv@xs4all.nl>
00012  *
00013  * See COPYING for copyright license.  If you did not receive a file called
00014  * COPYING with this source code, please notify the distributor of this mistake,
00015  * or contact the author.
00016  *
00017  *-------------------------------------------------------------------------
00018  */
00019 #include "pqxx/libcompiler.h"
00020 
00021 #include <deque>
00022 #include <map>
00023 #include <string>
00024 #include <vector>
00025 
00026 #include "pqxx/transaction_base"
00027 
00028 
00029 /* Methods tested in eg. self-test program test001 are marked with "//[t1]"
00030  */
00031 
00032 namespace pqxx
00033 {
00034 
00036 
00059 class PQXX_LIBEXPORT pipeline : public internal::transactionfocus
00060 {
00061 public:
00062   typedef unsigned query_id;
00063 
00064   explicit pipeline(transaction_base &t, 
00065       const PGSTD::string &PName="");                                   //[t69]
00066 
00067   ~pipeline() throw ();
00068 
00070 
00075   query_id insert(const PGSTD::string &);                               //[t69]
00076 
00078   void complete();                                                      //[t71]
00079 
00081   void flush();                                                         //[t70]
00082 
00084   bool is_running(query_id) const;                                      //[t71]
00085 
00087   bool is_finished(query_id) const;                                     //[t71]
00088 
00090 
00093   result retrieve(query_id);                                            //[t71]
00094 
00096   PGSTD::pair<query_id, result> retrieve();                             //[t69]
00097 
00098   bool empty() const throw ();                                          //[t69]
00099 
00101 
00117   void retain()                                 { m_retain = true; }    //[t70]
00118 
00120   void resume();                                                        //[t70]
00121 
00122 private:
00124   query_id generate_id();
00126   void send_waiting();
00128   void consumeresults();
00129 
00130   typedef PGSTD::map<query_id, result> ResultsMap;
00131   typedef PGSTD::map<query_id, PGSTD::string> QueryMap;
00132   typedef PGSTD::deque<query_id> QueryQueue;
00133 
00135   ResultsMap::value_type deliver(ResultsMap::iterator);
00136 
00137   QueryMap m_queries;
00138   QueryQueue m_waiting, m_sent;
00139   ResultsMap m_completed;
00140   query_id m_nextid;
00141   bool m_retain;
00142   bool m_error;
00143 
00145   pipeline(const pipeline &);
00147   pipeline &operator=(const pipeline &);
00148 };
00149 
00150 
00151 } // namespace
00152 
00153 

Generated on Mon May 10 13:19:09 2004 for libpqxx by doxygen 1.3.6-20040222