Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59125 - sandbox/transaction/dev
From: strasser_at_[hidden]
Date: 2010-01-18 09:22:49


Author: stefans
Date: 2010-01-18 09:22:48 EST (Mon, 18 Jan 2010)
New Revision: 59125
URL: http://svn.boost.org/trac/boost/changeset/59125

Log:
initial
Added:
   sandbox/transaction/dev/
   sandbox/transaction/dev/basic_loc.hpp (contents, props changed)
   sandbox/transaction/dev/basic_transaction.hpp (contents, props changed)
   sandbox/transaction/dev/basic_transaction_manager.hpp (contents, props changed)
   sandbox/transaction/dev/exception.hpp (contents, props changed)
   sandbox/transaction/dev/loc.hpp (contents, props changed)
   sandbox/transaction/dev/transaction.hpp (contents, props changed)
   sandbox/transaction/dev/transaction_manager.hpp (contents, props changed)

Added: sandbox/transaction/dev/basic_loc.hpp
==============================================================================
--- (empty file)
+++ sandbox/transaction/dev/basic_loc.hpp 2010-01-18 09:22:48 EST (Mon, 18 Jan 2010)
@@ -0,0 +1,38 @@
+// Copyright Stefan Strasser 2009 - 2010.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_PERSISTENT_BASIC_LOC_HPP
+#define BOOST_PERSISTENT_BASIC_LOC_HPP
+
+...
+
+namespace boost{
+
+namespace persistent{
+
+...
+
+namespace{
+template<class> class loc;
+}
+
+template<class T,class TxMgr>
+class basic_loc : public detail::loc_base{
+public:
+ //conversions for template pseudo-alias loc
+ operator loc<T> &(){ return *static_cast<loc<T> *>(this); }
+ operator loc<T> const &() const{ return *static_cast<loc<T> const *>(this); }
+ ...
+};
+
+
+}
+}
+
+
+
+#endif // BOOST_PERSISTENT_BASIC_LOC_HPP
+

Added: sandbox/transaction/dev/basic_transaction.hpp
==============================================================================
--- (empty file)
+++ sandbox/transaction/dev/basic_transaction.hpp 2010-01-18 09:22:48 EST (Mon, 18 Jan 2010)
@@ -0,0 +1,147 @@
+// Copyright Stefan Strasser 2009 - 2010.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_PERSISTENT_BASIC_TRANSACTION_HEADER_HPP
+#define BOOST_PERSISTENT_BASIC_TRANSACTION_HEADER_HPP
+
+#include <boost/noncopyable.hpp>
+
+namespace boost{
+namespace persistent{
+
+/// Begins a transaction on construction, and rolls it back on destruction if it was not yet
+/// committed.
+///
+/// Template parameters:
+/// \li \c TxMgr The transaction manager
+/// \brief A transaction scope
+template<class TxMgr>
+class basic_transaction : noncopyable{
+public:
+ /// Binds the new transaction to this thread.
+ /// If there already is an active transaction, the new transaction will be a nested transaction
+ /// of the active transaction.
+ ///
+ /// Throws: \c no_active_transaction_manager, \c finalize_error, \c io_failure, \c thread_resource_error
+ /// \brief Constructs a basic_transaction, beginning a new transaction scope
+ explicit basic_transaction()
+ : manager(TxMgr::active())
+ , tx(manager.begin_transaction())
+ , done(false){
+ this->manager.bind_transaction(this->tx);
+ }
+
+ /// The transaction is rolled back if it was not yet committed.
+ ///
+ /// Throws: Nothing
+ /// \brief Destructs the basic_transaction object
+ ~basic_transaction(){
+ if(!this->done){
+ try{
+ this->manager.rollback_transaction(this->tx);
+ }catch(...){
+#ifndef NDEBUG
+ std::cerr << "ignored exception" << std::endl;
+#endif
+ }
+ }
+ }
+
+ /// If this is a nested transaction, sets the active transaction to the parent transaction.
+ /// If this is a root transaction, resets the active transaction.
+ ///
+ /// Throws: \c isolation_exception,
+ /// \c archive_exception, \c io_failure, \c thread_resource_error, any exception thrown by the following user-supplied functions: \c T::T(), \c serialize(), \c save(), \c load(), \c construct(), \c equal(), \c finalize()
+ /// \brief Commits the transaction.
+ void commit(){
+ this->done=true;
+ this->manager.commit_transaction(this->tx);
+ }
+
+ /// If this is a nested transaction, sets the active transaction to the parent transaction.
+ /// If this is a root transaction, resets the active transaction.
+ ///
+ /// Throws: \c io_failure, \c thread_resource_error
+ /// \brief Unwinds all changes made during this transaction.
+ void rollback(){
+ this->done=true;
+ this->manager.rollback_transaction(this->tx);
+ }
+
+ /// Throws: Nothing
+ /// \brief Binds the current thread to this transaction
+ void bind(){
+ this->manager.bind_transaction(this->tx);
+ }
+
+ /// Throws: Nothing
+ /// \brief If the current thread is bound to this transaction, unbinds it
+ void unbind(){
+ if(this->manager.has_active_transaction() &&
+ &this->manager.active_transaction() == &this->tx){
+ this->manager.unbind_transaction();
+ }
+ }
+
+ /// \cond
+private:
+ TxMgr &manager;
+ typename TxMgr::transaction tx;
+ bool done;
+ /// \endcond
+};
+
+
+
+}
+}
+
+/// \brief Begins a new transaction scope.
+///
+/// BOOST_PERSISTENT_BASIC_ATOMIC and BOOST_PERSISTENT_BASIC_RETRY provide a simple syntax for
+/// concurrent transactions.
+///
+/// When used together the macros
+/// expand to a transaction scope that gets repeatedly executed until the transaction
+/// is successfully committed without conflicting with another transaction.
+///
+/// Example: \code
+/// #define atomic BOOST_PERSISTENT_ATOMIC
+/// #define retry BOOST_PERSISTENT_RETRY
+///
+/// atomic{
+/// ...
+/// } retry;
+/// \endcode expands to code that is equivalent to \code
+/// do{
+/// try{
+/// transaction tx;
+/// ...
+/// tx.commit();
+/// }catch(isolation_exception &i){
+/// i.unwind<transaction_manager>();
+/// continue;
+/// }
+/// }while(false); \endcode
+#define BOOST_PERSISTENT_BASIC_ATOMIC(TXMGR) \
+ do{ \
+ try{ \
+ boost::persistent::basic_transaction<TXMGR> ___tx;
+
+/// Ends a transaction scope.
+/// See BOOST_PERSISTENT_BASIC_ATOMIC for a detailed description.
+#define BOOST_PERSISTENT_BASIC_RETRY(TXMGR) \
+ ___tx.commit(); \
+ }catch(boost::persistent::isolation_exception &i){ \
+ i.unwind<TXMGR>(); \
+ continue; \
+ } \
+ }while(false);
+
+
+
+
+#endif //BOOST_PERSISTENT_BASIC_TRANSACTION_HEADER_HPP
\ No newline at end of file

Added: sandbox/transaction/dev/basic_transaction_manager.hpp
==============================================================================
--- (empty file)
+++ sandbox/transaction/dev/basic_transaction_manager.hpp 2010-01-18 09:22:48 EST (Mon, 18 Jan 2010)
@@ -0,0 +1,322 @@
+// Copyright Stefan Strasser 2009 - 2010.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_PERSISTENT_BASIC_TRANSACTION_MANAGER_HEADER_HPP
+#define BOOST_PERSISTENT_BASIC_TRANSACTION_MANAGER_HEADER_HPP
+
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/locks.hpp>
+#include <boost/thread/tss.hpp>
+#include <boost/persistent/detail/mutex.hpp>
+#include <boost/persistent/exception.hpp>
+#include <boost/persistent/detail/utility.hpp>
+#include <boost/persistent/detail/null_mutex.hpp>
+#include <boost/persistent/detail/mutex.hpp>
+#include <boost/type_traits/add_reference.hpp>
+#include <boost/fusion/include/mpl.hpp>
+#include <boost/fusion/include/as_vector.hpp>
+#include <boost/fusion/include/count_if.hpp>
+#include <boost/fusion/include/at.hpp>
+#include <boost/fusion/include/vector.hpp>
+#include <boost/fusion/include/is_sequence.hpp>
+#include <boost/utility/in_place_factory.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/transform.hpp>
+#include <boost/mpl/size.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/at.hpp>
+#include <boost/mpl/is_sequence.hpp>
+#include <boost/mpl/map.hpp>
+#include <boost/mpl/range_c.hpp>
+#include <boost/mpl/for_each.hpp>
+#include <boost/mpl/front.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/deref.hpp>
+#include <boost/mpl/find_if.hpp>
+#include <boost/mpl/contains.hpp>
+#include <boost/optional/optional.hpp>
+#include <boost/ref.hpp>
+
+
+
+namespace boost{
+namespace persistent{
+
+
+/// Model of TransactionManager. Only members that are not part of that concept are documented here.
+///
+/// Template parameters:
+/// \li \c Resources Either the type of the only resource manager used, or a MPL Sequence containing the types of the resource managers used.
+/// \li \c Threads \c true if multiple threads are used to access this transaction manager.
+/// \li \c TThreads \c true if multiple threads are used to access the same transaction. Can be \c false if multiple threads are used to access the transaction manager, but not to access the same transaction.
+/// \brief A transaction manager
+template<class Resources,bool Threads=true,bool TThreads=true>
+class basic_transaction_manager : noncopyable{
+/// \cond
+ BOOST_STATIC_ASSERT(Threads || !TThreads);
+private:
+ struct detail{
+ typedef typename mpl::if_<mpl::is_sequence<Resources>,Resources,mpl::vector<Resources> >::type resource_types;
+ template<class Service>
+ struct default_resource{
+ typedef typename mpl::deref<
+ typename mpl::find_if<
+ resource_types,
+ persistent::detail::resource_has_service<mpl::_1,Service>
+ >::type
+ >::type::tag type;
+ };
+ typedef typename mpl::transform<resource_types,add_reference<mpl::_1> >::type resource_references;
+ typedef typename fusion::result_of::as_vector<resource_references>::type resources_tuple;
+
+ class transaction;
+ class transaction_construct_t{
+ explicit transaction_construct_t(transaction *parent) : parent(parent){}
+ friend class basic_transaction_manager;
+ transaction *parent;
+ };
+
+ template<class Resource> struct get_optional_transaction{
+ typedef optional<typename Resource::transaction> type;
+ };
+ typedef typename mpl::transform<resource_types,get_optional_transaction<mpl::_1> >::type optional_transaction_types;
+ typedef typename fusion::result_of::as_vector<optional_transaction_types>::type optional_transaction_tuple;
+
+ class transaction : noncopyable{
+ public:
+ transaction(transaction_construct_t const &c) : parent(c.parent){}
+ private:
+ friend class basic_transaction_manager;
+
+ transaction * const parent;
+ optional_transaction_tuple resource_transactions;
+
+ typedef typename mpl::if_c<
+ TThreads,
+ persistent::detail::mutex_type,
+ persistent::detail::null_mutex
+ >::type mutex_type;
+
+ mutex_type mutex;
+ };
+ };
+ /// \endcond
+public:
+ typedef typename detail::transaction transaction;
+ typedef typename detail::resource_types resource_types;
+ template<class ServiceTag>
+ struct default_resource{
+ typedef typename detail::template default_resource<ServiceTag>::type type;
+ };
+
+ /// This constructor is only available if this transaction manager uses only one
+ /// resource manager.
+ ///
+ /// Throws: Nothing
+ /// \brief Constructs a basic_transaction_manager using the passed resource manager
+ /// \param resource The resource manager
+ explicit basic_transaction_manager(typename mpl::front<resource_types>::type &resource)
+ : resources(ref(resource))
+ , activetx(){
+ BOOST_STATIC_ASSERT(mpl::size<resource_types>::value==1);
+ this->bind();
+ }
+
+ /// Throws: Nothing
+ /// \brief Constructs a basic_transaction_manager using the passed resource managers
+ /// \param resources A Boost.Fusion Sequence of non-const references to the resource
+ /// managers. For example, fusion::vector<res1_type &,res2_type &>
+ explicit basic_transaction_manager(typename detail::resources_tuple const &resources)
+ : resources(resources)
+ , activetx(){
+ this->bind();
+ }
+
+ template<class Tag>
+ typename persistent::detail::type_by_tag<resource_types,Tag>::type &resource(Tag tag=Tag()){
+ typedef typename persistent::detail::index_by_tag<resource_types,Tag>::type index;
+ return fusion::at<index>(this->resources);
+ }
+
+ template<class Tag>
+ typename persistent::detail::type_by_tag<resource_types,Tag>::type::transaction &
+ resource_transaction(transaction &tx,Tag tag=Tag()){
+ typedef typename persistent::detail::type_by_tag<resource_types,Tag>::type resource_type;
+ typedef typename persistent::detail::index_by_tag<resource_types,Tag>::type index;
+ optional<typename resource_type::transaction> &rtx=fusion::at<index>(tx.resource_transactions);
+
+ //TODO optimization: mutex lock could be avoided if a resource transaction of this
+ //resource is created in each global transaction, so the resource transaction can be
+ //created in basic_transaction_manager::begin_transaction() instead.
+ //e.g. determined by if this resource
+ //manager is the only one, or according to user configuration.
+ lock_guard<typename transaction::mutex_type> l(tx.mutex);
+ if(!rtx){
+ resource_type &resource=fusion::at<index>(this->resources);
+ if(tx.parent){
+ //TODO optimization: if 10 nested transactions were created in one resource manager,
+ //and then a second resource manager is called for the first time in the innermost
+ //transaction, 10 nested transactions are created in the second resource manager,
+ //even though it would be enough to create one transaction
+ //that gets committed only when the outermost global transaction is committed.
+
+ typename resource_type::transaction &parentrtx=this->resource_transaction<Tag>(*tx.parent);
+ rtx=in_place(resource.begin_nested_transaction(parentrtx));
+ }else{
+ rtx=in_place(resource.begin_root_transaction());
+ }
+ }
+ return *rtx;
+ }
+
+ typename detail::transaction_construct_t begin_transaction(){
+ if(this->has_active_transaction()) return typename detail::transaction_construct_t(&this->active_transaction());
+ else return typename detail::transaction_construct_t(0);
+ }
+
+ void commit_transaction(transaction &tx){
+ this->bind_transaction(tx);
+
+ try{
+ std::size_t nr=fusion::count_if(tx.resource_transactions,is());
+ if(nr > 0){
+ if(nr == 1){
+ //FIXME the local transaction commit might access other resource managers
+ //(e.g. for reference counting). that can start another resource transaction
+ //and a two-phase-commit must take place.
+ //finish-phase must be introduced to make sure the commit itself doesn't
+ //access other resource managers
+ this->for_each_transaction(tx,committer());
+ }else{
+ persistent::detail::throw_(unsupported_exception()); //TODO distributed transaction
+ }
+ }
+ }catch(...){ //commit_transaction is called exactly once, even if something goes wrong. unbind transaction:
+ if(tx.parent) this->bind_transaction(*tx.parent);
+ else this->unbind_transaction();
+ throw;
+ }
+ if(tx.parent) this->bind_transaction(*tx.parent);
+ else this->unbind_transaction();
+ }
+
+ void rollback_transaction(transaction &tx){
+ this->bind_transaction(tx);
+
+ try{ this->for_each_transaction(tx,rollbacker()); }
+ catch(...){
+ if(tx.parent) this->bind_transaction(*tx.parent);
+ else this->unbind_transaction();
+ throw;
+ }
+
+ if(tx.parent) this->bind_transaction(*tx.parent);
+ else this->unbind_transaction();
+ }
+
+ void bind_transaction(transaction &tx){
+ this->active_transaction(&tx,mpl::bool_<Threads>());
+ }
+ void unbind_transaction(){
+ this->active_transaction(0,mpl::bool_<Threads>());
+ }
+
+ transaction &active_transaction() const{
+ if(transaction *tx=this->active_transaction(mpl::bool_<Threads>())) return *tx;
+ else persistent::detail::throw_(no_active_transaction());
+ }
+ bool has_active_transaction() const{
+ return this->active_transaction(mpl::bool_<Threads>()) ? true : false;
+ }
+
+ static bool has_active(){
+ return active_;
+ }
+
+ static basic_transaction_manager &active(){
+ if(active_) return *active_;
+ else persistent::detail::throw_(no_active_transaction_manager());
+ }
+ void bind(){ active_=this; }
+ static void unbind(){ active_=0; }
+
+ /// \cond
+private:
+ struct is{
+ typedef bool result_type;
+ template<class T>
+ bool operator()(T const &t) const{ return t; }
+ };
+ struct committer{
+ template<class ResMgr,class Tx>
+ void operator()(ResMgr &rmgr,Tx &tx) const{
+ rmgr.commit_transaction(tx);
+ }
+ };
+ struct rollbacker{
+ template<class ResMgr,class Tx>
+ void operator()(ResMgr &rmgr,Tx &tx) const{
+ rmgr.rollback_transaction(tx);
+ }
+ };
+ template<class F>
+ struct for_each_helper{
+ explicit for_each_helper(basic_transaction_manager *this_,transaction &tx,F const &f) : this_(this_),tx(tx),f(f){}
+ template<class U>
+ void operator()(U) const{
+ typedef typename mpl::at<resource_types,U>::type resource_type;
+ optional<typename resource_type::transaction> &rtx=fusion::at<U>(tx.resource_transactions);
+ if(rtx){
+ resource_type &rmgr=fusion::at<U>(this_->resources);
+ f(rmgr,*rtx);
+ }
+ }
+ private:
+ basic_transaction_manager *this_;
+ transaction &tx;
+ F f;
+ };
+ template<class F>
+ void for_each_transaction(transaction &tx,F const &f){
+ static unsigned int const size=mpl::size<resource_types>::type::value;
+ typedef mpl::range_c<unsigned int,0,size> range;
+ mpl::for_each<range>(for_each_helper<F>(this,tx,f));
+ }
+ void active_transaction(transaction *newtx,mpl::true_){
+ if(transaction **tx=this->activetx.get()) *tx=newtx;
+ else this->activetx.reset(new transaction *(newtx));
+ }
+ void active_transaction(transaction *newtx,mpl::false_){
+ this->activetx=newtx;
+ }
+ transaction *active_transaction(mpl::true_) const{
+ if(transaction **tx=this->activetx.get()){
+ if(*tx) return *tx;
+ }
+ return 0;
+ }
+ transaction *active_transaction(mpl::false_) const{
+ return this->activetx;
+ }
+
+ typename detail::resources_tuple const resources;
+ //TODO optimization: use thread local variable instead of thread_specific_ptr
+ typename mpl::if_c<Threads,thread_specific_ptr<transaction *>,transaction *>::type activetx;
+ static basic_transaction_manager *active_;
+ /// \endcond
+};
+
+template<class Resources,bool Threads,bool TThreads>
+basic_transaction_manager<Resources,Threads,TThreads> *basic_transaction_manager<Resources,Threads,TThreads>::active_=0;
+
+}
+}
+
+
+
+#endif // BOOST_PERSISTENT_BASIC_TRANSACTION_MANAGER_HEADER_HPP
\ No newline at end of file

Added: sandbox/transaction/dev/exception.hpp
==============================================================================
--- (empty file)
+++ sandbox/transaction/dev/exception.hpp 2010-01-18 09:22:48 EST (Mon, 18 Jan 2010)
@@ -0,0 +1,117 @@
+// Copyright Stefan Strasser 2009 - 2010.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_PERSISTENT_EXCEPTION_HEADER_HPP
+#define BOOST_PERSISTENT_EXCEPTION_HEADER_HPP
+
+#include <exception>
+#include <boost/mpl/begin.hpp>
+#include <boost/mpl/end.hpp>
+#include <boost/mpl/next.hpp>
+#include <boost/mpl/deref.hpp>
+#include <boost/assert.hpp>
+#include <boost/exception/detail/attribute_noreturn.hpp>
+
+
+namespace boost{
+namespace persistent{
+
+namespace detail{
+
+template<class T>
+BOOST_ATTRIBUTE_NORETURN void throw_(T const &e){
+ throw e;
+}
+
+}
+
+///Exception base class.
+struct exception : std::exception{};
+
+///Indicates that a database recovery using its transaction log failed.
+struct recovery_failure : persistent::exception{};
+
+///Indicates that internal operations reading from/writing to database files failed.
+struct io_failure : persistent::exception{};
+
+///Indicates that there was an attempt to modify the database from a user-supplied \c finalize() function.
+struct finalize_error : persistent::exception{};
+
+///Indicates that the operation required an active transaction but there was no active transaction set for this thread.
+struct no_active_transaction : persistent::exception{};
+
+///Indicates that the operation required an active transaction manager but there is none set.
+struct no_active_transaction_manager : persistent::exception{};
+
+///Indicates that the operation is not supported by this implementation
+struct unsupported_exception : persistent::exception{};
+
+struct isolation_exception;
+
+namespace detail{
+
+template<class ResMgr>
+struct visolation_exception;
+
+template<class TxMgr,class Iterator>
+struct isolation_unwind_visitor{
+ void operator()(TxMgr &txmgr,isolation_exception const &iso){
+ typedef typename mpl::deref<Iterator>::type resource_type;
+ if(visolation_exception<resource_type> const *viso=dynamic_cast<visolation_exception<resource_type> const *>(&iso)){
+ viso->unwind(txmgr);
+ }else{
+ isolation_unwind_visitor<TxMgr,typename mpl::next<Iterator>::type> visit;
+ visit(txmgr,iso);
+ }
+ }
+};
+
+template<class TxMgr>
+struct isolation_unwind_visitor<TxMgr,typename mpl::end<typename TxMgr::resource_types>::type>{
+ void operator()(TxMgr &,isolation_exception const &){
+ BOOST_ASSERT(false);
+ }
+};
+
+}
+
+///Indicates that the operation conflicted with another transaction.
+struct isolation_exception : persistent::exception{
+ ///Rethrows the exception if the active transaction is a nested transaction but the isolation exception was caused by a parent transaction of it.
+ template<class TxMgr>
+ void unwind(TxMgr &txmgr=TxMgr::active()) const{ //pseudo-virtual
+ detail::isolation_unwind_visitor<TxMgr,typename mpl::begin<typename TxMgr::resource_types>::type> visit;
+ visit(txmgr,*this);
+ }
+};
+
+
+namespace detail{
+
+template<class ResMgr>
+struct visolation_exception : isolation_exception{
+ visolation_exception(typename ResMgr::transaction *unwind_to) : to(unwind_to){}
+ template<class TxMgr>
+ void unwind(TxMgr &txmgr) const{ //pseudo-virtual
+ if(this->to){
+ typename ResMgr::transaction &tx=txmgr.template resource_transaction<typename ResMgr::tag>(txmgr.active_transaction());
+ if(&tx != this->to) throw;
+ }else if(txmgr.has_active_transaction()) throw;
+ }
+private:
+ typename ResMgr::transaction *to;
+};
+
+}
+
+
+
+}
+}
+
+
+
+#endif // BOOST_PERSISTENT_EXCEPTION_HEADER_HPP

Added: sandbox/transaction/dev/loc.hpp
==============================================================================
--- (empty file)
+++ sandbox/transaction/dev/loc.hpp 2010-01-18 09:22:48 EST (Mon, 18 Jan 2010)
@@ -0,0 +1,60 @@
+// Copyright Stefan Strasser 2009 - 2010.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_PERSISTENT_DEFAULT_LOC_HPP
+#define BOOST_PERSISTENT_DEFAULT_LOC_HPP
+
+#include <boost/persistent/basic_loc.hpp>
+#include <boost/persistent/transaction_manager.hpp>
+
+namespace boost{
+namespace persistent{
+
+#ifdef DOXYGEN
+
+/// \brief A template alias of \c basic_loc using the default transaction manager
+///
+/// \code
+/// template<class T>
+/// using loc = basic_loc<T,transaction_manager>;
+/// \endcode
+/// In C++98, \c loc ist implemented as a class that acts like a template alias.
+template<class T>
+class loc{};
+
+#else
+
+namespace{
+
+template<class T>
+class loc : public basic_loc<T,transaction_manager>{
+private:
+ typedef basic_loc<T,transaction_manager> base;
+public:
+ //forwarding constructors:
+ loc(){}
+ template<class Y>
+ loc(loc<Y> const &o) : base(o){}
+ template<class Y>
+ loc(basic_loc<Y,transaction_manager> const &o) : base(o){}
+ explicit loc(typename remove_const<T>::type *p) : base(p){}
+ template<class Tag>
+ loc(typename remove_const<T>::type *p,Tag tag) : base(p,tag){}
+};
+
+}
+
+#endif
+
+}
+
+...
+
+}
+
+
+
+#endif
\ No newline at end of file

Added: sandbox/transaction/dev/transaction.hpp
==============================================================================
--- (empty file)
+++ sandbox/transaction/dev/transaction.hpp 2010-01-18 09:22:48 EST (Mon, 18 Jan 2010)
@@ -0,0 +1,35 @@
+// Copyright Stefan Strasser 2009 - 2010.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_PERSISTENT_DEFAULT_TRANSACTION_HEADER_HPP
+#define BOOST_PERSISTENT_DEFAULT_TRANSACTION_HEADER_HPP
+
+#include <boost/persistent/basic_transaction.hpp>
+#include <boost/persistent/transaction_manager.hpp>
+
+
+namespace boost{
+namespace persistent{
+
+/// \brief An alias of \c basic_transaction using the default transaction manager
+typedef basic_transaction<transaction_manager> transaction;
+
+
+}
+}
+
+
+
+/// \brief An alias of BOOST_PERSISTENT_BASIC_ATOMIC using the default transaction manager
+#define BOOST_PERSISTENT_ATOMIC \
+ BOOST_PERSISTENT_BASIC_ATOMIC(boost::persistent::transaction_manager)
+
+/// \brief An alias of BOOST_PERSISTENT_BASIC_RETRY using the default transaction manager
+#define BOOST_PERSISTENT_RETRY \
+ BOOST_PERSISTENT_BASIC_RETRY(boost::persistent::transaction_manager)
+
+
+#endif //BOOST_PERSISTENT_TRANSACTION_HEADER_HPP
\ No newline at end of file

Added: sandbox/transaction/dev/transaction_manager.hpp
==============================================================================
--- (empty file)
+++ sandbox/transaction/dev/transaction_manager.hpp 2010-01-18 09:22:48 EST (Mon, 18 Jan 2010)
@@ -0,0 +1,58 @@
+// Copyright Stefan Strasser 2009 - 2010.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_PERSISTENT_TRANSACTION_MANAGER_HPP
+#define BOOST_PERSISTENT_TRANSACTION_MANAGER_HPP
+
+
+#ifndef BOOST_PERSISTENT_CONFIGURATION
+
+#include <boost/persistent/basic_transaction_manager.hpp>
+#include <boost/persistent/multiversion_object_resource.hpp>
+#include <boost/persistent/redo_storage.hpp>
+#include <boost/persistent/block_storage.hpp>
+#include <boost/persistent/mapped_file_block.hpp>
+
+/// Is only defined if BOOST_PERSISTENT_CONFIGURATION is not yet defined.
+///
+/// Default configuration:
+/// \code
+/// boost::persistent::basic_transaction_manager<
+/// boost::persistent::multiversion_object_resource<
+/// boost::persistent::redo_storage<
+/// boost::persistent::block_storage<
+/// boost::persistent::mapped_file_block
+/// >
+/// >
+/// >
+/// >
+/// \endcode
+/// \brief Defines the default configuration, using the default transaction manager
+#define BOOST_PERSISTENT_CONFIGURATION \
+ boost::persistent::basic_transaction_manager< \
+ boost::persistent::multiversion_object_resource< \
+ boost::persistent::redo_storage< \
+ boost::persistent::block_storage< \
+ boost::persistent::mapped_file_block \
+ > \
+ > \
+ > \
+ >
+
+#endif
+
+
+namespace boost{
+namespace persistent{
+
+/// \brief An alias of the configured transaction manager
+typedef BOOST_PERSISTENT_CONFIGURATION transaction_manager;
+
+
+}
+}
+
+#endif //BOOST_PERSISTENT_TRANSACTION_MANAGER_HPP
\ No newline at end of file


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk