/usr/share/cruisecontrol-bin-2.6.1/projects/qpid-trunk/cpp/src/qpid/broker/DtxWorkRecord.h

00001 /*
00002  *
00003  * Licensed to the Apache Software Foundation (ASF) under one
00004  * or more contributor license agreements.  See the NOTICE file
00005  * distributed with this work for additional information
00006  * regarding copyright ownership.  The ASF licenses this file
00007  * to you under the Apache License, Version 2.0 (the
00008  * "License"); you may not use this file except in compliance
00009  * with the License.  You may obtain a copy of the License at
00010  * 
00011  *   http://www.apache.org/licenses/LICENSE-2.0
00012  * 
00013  * Unless required by applicable law or agreed to in writing,
00014  * software distributed under the License is distributed on an
00015  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00016  * KIND, either express or implied.  See the License for the
00017  * specific language governing permissions and limitations
00018  * under the License.
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

Generated on Thu Apr 10 11:08:17 2008 for Qpid by  doxygen 1.4.7