Exemplo n.º 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()
Exemplo n.º 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()
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)))
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)))
Exemplo n.º 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)