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, 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/compiler.h"
00020 
00021 #include <map>
00022 #include <string>
00023 
00024 #include "pqxx/transaction_base"
00025 
00026 
00027 /* Methods tested in eg. self-test program test1 are marked with "//[t1]"
00028  */
00029 
00030 namespace pqxx
00031 {
00032 
00033 // TODO: Warning for unretrieved results
00034 // TODO: "sessionfocus" class (common base with tablestream) to block xaction
00035 // TODO: Attach & detach to/from transaction dynamically
00036 // TODO: Restartable pipelines for fault tolerance (use transactor?)
00037 
00038 
00040 
00057 class PQXX_LIBEXPORT pipeline
00058 {
00059 public:
00060   explicit pipeline(transaction_base &t) :                              //[]
00061     m_home(t), m_queries(), m_waiting(), m_completed(), m_nextid(1) {}
00062 
00063   typedef unsigned query_id;
00064 
00066   query_id insert(const PGSTD::string &);                               //[]
00067 
00069   void drain();                                                         //[]
00070 
00072   void flush();                                                         //[]
00073 
00074   // TODO: One cancel may require several queries to be restarted!
00076   void cancel(query_id);                                                //[]
00077 
00078   // TODO: There's some lifecycle ugliness in combination with cancel()
00080   bool is_running(query_id) const;                                      //[]
00081 
00083   bool is_finished(query_id) const;                                     //[]
00084 
00086 
00089   PGSTD::pair<query_id, result> retrieve(query_id);                     //[]
00090 
00092   result retrieve();                                                    //[]
00093 
00094   bool empty() const throw ();                                          //[]
00095 
00096 private:
00098   void attach();
00100   void detach();
00102   void send_waiting();
00104   void consumeresults();
00105 
00106   transaction_base &m_home;
00107   PGSTD::map<query_id, PGSTD::string> m_queries;
00108   PGSTD::vector<query_id> m_waiting, m_sent;
00109   PGSTD::map<query_id, result> m_completed;
00110   query_id m_nextid;
00111 
00113   pipeline(const pipeline &);
00115   pipeline &operator=(const pipeline &);
00116 };
00117 
00118 
00119 } // namespace
00120 
00121 

Generated on Thu Dec 25 07:16:37 2003 for libpqxx by doxygen 1.3.4