00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _DtxWorkRecord_
00022 #define _DtxWorkRecord_
00023
00024 #include "DtxBuffer.h"
00025 #include "DtxTimeout.h"
00026 #include "TransactionalStore.h"
00027
00028 #include "qpid/framing/amqp_types.h"
00029 #include "qpid/sys/Mutex.h"
00030
00031 #include <algorithm>
00032 #include <functional>
00033 #include <vector>
00034
00035 #include <boost/intrusive_ptr.hpp>
00036
00037 namespace qpid {
00038 namespace broker {
00039
00045 class DtxWorkRecord
00046 {
00047 typedef std::vector<DtxBuffer::shared_ptr> Work;
00048
00049 const std::string xid;
00050 TransactionalStore* const store;
00051 bool completed;
00052 bool rolledback;
00053 bool prepared;
00054 bool expired;
00055 boost::intrusive_ptr<DtxTimeout> timeout;
00056 Work work;
00057 std::auto_ptr<TPCTransactionContext> txn;
00058 qpid::sys::Mutex lock;
00059
00060 bool check();
00061 void abort();
00062 bool prepare(TransactionContext* txn);
00063 public:
00064 DtxWorkRecord(const std::string& xid, TransactionalStore* const store);
00065 ~DtxWorkRecord();
00066 bool prepare();
00067 bool commit(bool onePhase);
00068 void rollback();
00069 void add(DtxBuffer::shared_ptr ops);
00070 void recover(std::auto_ptr<TPCTransactionContext> txn, DtxBuffer::shared_ptr ops);
00071 void timedout();
00072 void setTimeout(boost::intrusive_ptr<DtxTimeout> t) { timeout = t; }
00073 boost::intrusive_ptr<DtxTimeout> getTimeout() { return timeout; }
00074 };
00075
00076 }
00077 }
00078
00079 #endif