00001 #ifndef QPID_CLUSTER_OUTPUTINTERCEPTOR_H
00002 #define QPID_CLUSTER_OUTPUTINTERCEPTOR_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "WriteEstimate.h"
00026 #include "qpid/sys/ConnectionOutputHandler.h"
00027 #include "qpid/broker/ConnectionFactory.h"
00028 #include <boost/function.hpp>
00029
00030 namespace qpid {
00031 namespace framing { class AMQFrame; }
00032 namespace cluster {
00033
00034 class Connection;
00035
00039 class OutputInterceptor : public sys::ConnectionOutputHandler {
00040 public:
00041 OutputInterceptor(cluster::Connection& p, sys::ConnectionOutputHandler& h);
00042
00043
00044 void send(framing::AMQFrame& f);
00045 void activateOutput();
00046 void close();
00047 size_t getBuffered() const;
00048
00049
00050 void deliverDoOutput(size_t requested);
00051
00052 bool doOutput();
00053
00054 void setOutputHandler(sys::ConnectionOutputHandler& h);
00055
00056 cluster::Connection& parent;
00057
00058 private:
00059 typedef sys::Mutex::ScopedLock Locker;
00060
00061 void startDoOutput();
00062 void sendDoOutput();
00063
00064 mutable sys::Mutex lock;
00065 sys::ConnectionOutputHandler* next;
00066 size_t sent;
00067 WriteEstimate writeEstimate;
00068 bool moreOutput;
00069 bool doingOutput;
00070 };
00071
00072 }}
00073
00074 #endif