コード例 #1
0
    def doCommute(self, ref, fn, args):
        """
        Sets the in-transaction-value of this ref to the given value, but does not require
        other transactions that also change this ref to retry. Commutes are re-computed at
        commit time and apply on top of any more recent changes.
        """
        if not self._info or not self._info.running():
            self._retry("RETRY - Not running in doCommute!")

        # If we don't have an in-transaction-value yet for this ref
        #  get the latest one
        if not ref in self._vals:
            with shared_lock(ref._lock):
                val = ref._tvals.val if ref._tvals else None

            self._vals[ref] = val

        # Add this commute function to the end of the list of commutes for this ref
        self._commutes.setdefault(ref, []).append([fn, args])
        # Save the value we get by applying the fn now to our in-transaction-list
        returnValue = fn(*RT.cons(self._vals[ref], args))
        self._vals[ref] = returnValue

        return returnValue
コード例 #2
0
ファイル: threadutil.py プロジェクト: HatsuneMiku/clojure-py
 def get(self):
     with shared_lock(self._lock): return self._v
コード例 #3
0
ファイル: threadutil.py プロジェクト: yminer/clojure-py
 def get(self):
     with shared_lock(self._lock):
         return self._v