Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53082 - sandbox/stm/boost/stm
From: justin_at_[hidden]
Date: 2009-05-18 05:17:30


Author: jgottschlich
Date: 2009-05-18 05:17:29 EDT (Mon, 18 May 2009)
New Revision: 53082
URL: http://svn.boost.org/trac/boost/changeset/53082

Log:
added shared named pointer allocation support for TBoost.STM. Corrected some other minor problems.
Text files modified:
   sandbox/stm/boost/stm/transaction.hpp | 48 +++++++++++++++++++++++++++++++++++----
   1 files changed, 43 insertions(+), 5 deletions(-)

Modified: sandbox/stm/boost/stm/transaction.hpp
==============================================================================
--- sandbox/stm/boost/stm/transaction.hpp (original)
+++ sandbox/stm/boost/stm/transaction.hpp 2009-05-18 05:17:29 EDT (Mon, 18 May 2009)
@@ -462,7 +462,11 @@
    size_t const writes() const { return writeListRef_->size(); }
    size_t const reads() const { return reads_; }
 
- template <typename T> T const * read_ptr(T const * in) { return &read(*in); }
+ template <typename T> T const * read_ptr(T const * in)
+ {
+ if (NULL == in) return NULL;
+ return &read(*in);
+ }
    template <typename T> T const & r(T const & in) { return read(in); }
 
    //--------------------------------------------------------------------------
@@ -520,7 +524,11 @@
    }
 
    //--------------------------------------------------------------------------
- template <typename T> T* write_ptr(T* in) { return &write(*in); }
+ template <typename T> T* write_ptr(T* in)
+ {
+ if (NULL == in) return NULL;
+ return &write(*in);
+ }
    template <typename T> T& w(T& in) { return write(in); }
 
    //--------------------------------------------------------------------------
@@ -566,7 +574,34 @@
 
    //--------------------------------------------------------------------------
    template <typename T>
- T* new_memory()
+ T* new_shared_memory(T*)
+ {
+ if (forced_to_abort())
+ {
+ if (!directUpdating_)
+ {
+ deferred_abort(true);
+ throw aborted_tx("");
+ }
+
+#ifndef DELAY_INVALIDATION_DOOMED_TXS_UNTIL_COMMIT
+ cm_->abort_on_new(*this);
+#endif
+ }
+
+ make_irrevocable();
+
+ T *newNode = new T;
+ newNode->transaction_thread(threadId_);
+ newNode->new_memory(1);
+ newMemoryList().push_back(newNode);
+
+ return newNode;
+ }
+
+ //--------------------------------------------------------------------------
+ template <typename T>
+ T* new_memory(T*)
    {
       if (forced_to_abort())
       {
@@ -583,7 +618,7 @@
       T *newNode = new T();
       newNode->transaction_thread(threadId_);
       newNode->new_memory(1);
- newMemoryList().push_front(newNode);
+ newMemoryList().push_back(newNode);
 
       return newNode;
    }
@@ -624,7 +659,10 @@
    void no_throw_end();
 
    void force_to_abort()
- {
+ {
+ // can't abort irrevocable transactions
+ if (irrevocable()) return;
+
       *forcedToAbortRef_ = true;
 
 #ifdef PERFORMING_COMPOSITION


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