コード例 #1
0
        internal static bool createServerObject(int uid, int txID, string clientURL)
        {
            if (_serverObjects.Any((x => x.UID == uid && x.WRITETS == 0)))
            {
                return(false);
            }

            TentativeTx tx;

            if (!_tentativeTransactions.ContainsKey(txID))
            {
                tx = createTentativeTx(txID, clientURL);
            }
            else
            {
                tx = _tentativeTransactions[txID];
            }

            ServerObject obj = new ServerObject(uid);

            tx.AddObject(obj);
            return(true);
        }
コード例 #2
0
        /**
         * Registers a tentative Write
         * @return TRUE if the value could be written
         * @return FALSE if the write is in conflict, cascading into an abort Tx
         **/
        internal static bool regTentativeWrite(int uid, int newVal, int txID, string clientURL)
        {
            if (!_tentativeTransactions.ContainsKey(txID))
            {
                createTentativeTx(txID, clientURL);
            }

            List <ServerObject> versions = getVersionsByUID(uid, txID);
            int earlierReadTS            = versions.Max(readts => readts.READTS);

            if (earlierReadTS <= txID)
            {
                ServerObject tentativeWrite = new ServerObject(uid, newVal, txID);

                TentativeTx tx = _tentativeTransactions[txID];
                tx.AddObject(tentativeWrite);

                return(true); // proceed with transaction
            }
            else
            {
                return(false); // abort transaction
            }
        }
コード例 #3
0
 internal void AddObject(ServerObject obj)
 {
     writtenObjects.Add(obj);
 }