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() { Locker l(lock); next.close(); }
00047 size_t getBuffered() const { Locker l(lock); return next.getBuffered(); }
00048
00049
00050 void deliverDoOutput(size_t requested);
00051
00052 bool doOutput();
00053
00054 cluster::Connection& parent;
00055
00056 private:
00057 typedef sys::Mutex::ScopedLock Locker;
00058
00059 void startDoOutput();
00060 void sendDoOutput();
00061
00062 mutable sys::Mutex lock;
00063 sys::ConnectionOutputHandler& next;
00064 size_t sent;
00065 WriteEstimate writeEstimate;
00066 bool moreOutput;
00067 bool doingOutput;
00068 };
00069
00070 }}
00071
00072 #endif