コード例 #1
0
  private void setStatus(int aStatus, TransactionException aTE) {
    // Make sure we only do this once
    //
    synchronized (this) {
      if (theStatus == DECEASED) return;

      theStatus = aStatus;
      theException = aTE;
    }

    if (shouldUpdate) theDynamicView.getSearchTask().taint();

    if (theTxn.isNull()) {
      try {
        TxnDispatcher.get().prepareAndCommit(theTxn);
      } catch (UnknownTransactionException aUTE) {
        /*
          Don't care much...if we got here, we're defining state
          and everyone else will fail at the status test above
        */
        synchronized (this) {
          theException = aUTE;
        }
      }
    }
  }
コード例 #2
0
    public int offer(SearchOffer anOffer) {
      OpInfo myInfo = anOffer.getInfo();

      // Try the lock
      LockMgr myMgr = TxnLocks.getLockMgr(myInfo.getType());
      TxnLock myLock = myMgr.getLock(myInfo.getOID());

      int myResult;

      synchronized (myLock) {
        myResult = myLock.acquire(theTxn, TxnLock.READ, null, null, false);
      }

      if (myResult == TxnLock.SUCCESS) {
        if (keepLock) {
          /*
           Need to track the lock under the transaction
          */
          try {
            theTxn.add(new EntryTxnOp(TxnLock.READ, myInfo, myLock));
          } catch (TransactionException aTE) {
            myLock.release(theTxn, TxnLock.READ);
            theFailure = aTE;
            return STOP;
          }
        } else {
          /*
           No need to track this lock, we were just testing so
           we can release it now
          */
          myLock.release(theTxn, TxnLock.READ);
        }

        theEntry = anOffer.getEntry();
      }

      return STOP;
    }