Example #1
0
 def deref(self):
     """Returns either the in-transaction-value of this ref if
     there is an active transaction, or returns the last committed
     value of ref"""
     transaction = LockingTransaction.get()
     if transaction:
         return transaction.getRef(self)
     return self._currentVal()
Example #2
0
 def deref(self):
     """Returns either the in-transaction-value of this ref if
     there is an active transaction, or returns the last committed
     value of ref"""
     transaction = LockingTransaction.get()
     if transaction:
         return transaction.getRef(self)
     return self._currentVal()
Example #3
0
 def touch(self):
     """Ensures that this ref cannot be given a new
     in-transaction-value by any other transactions for the
     duration of this transaction"""
     LockingTransaction.ensureGet().doEnsure(self)
Example #4
0
 def commute(self, fn, args):
     """Commutes the value of this ref, allowing for it to be
     updated by other transactions before the commuting function is
     called"""
     return LockingTransaction.ensureGet().doCommute(self, fn, args)
Example #5
0
 def alter(self, fn, args):
     "Alters the value of this ref, and returns the new state"
     current = LockingTransaction.ensureGet().getRef(self)
     return self.refSet(fn(*RT.cons(current, args)))
Example #6
0
 def refSet(self, state):
     """Sets the value of this ref to the desired state, regardless
     of the current value. Returns the newly set state"""
     return LockingTransaction.ensureGet().doSet(self, state)
Example #7
0
 def touch(self):
     """Ensures that this ref cannot be given a new
     in-transaction-value by any other transactions for the
     duration of this transaction"""
     LockingTransaction.ensureGet().doEnsure(self)
Example #8
0
 def commute(self, fn, args):
     """Commutes the value of this ref, allowing for it to be
     updated by other transactions before the commuting function is
     called"""
     return LockingTransaction.ensureGet().doCommute(self, fn, args)
Example #9
0
 def alter(self, fn, args):
     "Alters the value of this ref, and returns the new state"
     current = LockingTransaction.ensureGet().getRef(self)
     return self.refSet(fn(*RT.cons(current, args)))
Example #10
0
 def refSet(self, state):
     """Sets the value of this ref to the desired state, regardless
     of the current value. Returns the newly set state"""
     return LockingTransaction.ensureGet().doSet(self, state)