예제 #1
0
        public static LockRequest ForAcquire(LockMode mode, ref DbEntry obj)
        {
            LockRequest lr =
                new LockRequest(LockOperation.Acquire, mode, 0, ref obj, new Lock());

            return(lr);
        }
예제 #2
0
        public static LockRequest ForTimeout()
        {
            LockRequest lr = new LockRequest();

            lr.op = LockOperation.Timeout;
            return(lr);
        }
예제 #3
0
        public static LockRequest ForReleaseAll()
        {
            LockRequest lr = new LockRequest();

            lr.op = LockOperation.ReleaseAll;
            return(lr);
        }
예제 #4
0
        public static LockRequest ForAcquireWithTimeout(LockMode mode, int timeout, ref DbEntry obj)
        {
            LockRequest lr =
                new LockRequest(LockOperation.AcquireTimeout, mode, timeout, ref obj, new Lock());

            return(lr);
        }
예제 #5
0
        public static LockRequest ForReleaseObj(ref DbEntry obj)
        {
            LockRequest lr = new LockRequest();

            lr.op  = LockOperation.ReleaseObj;
            lr.obj = obj;
            return(lr);
        }
예제 #6
0
        public static LockRequest ForRelease(Lock lck)
        {
            LockRequest lr = new LockRequest();

            lr.op  = LockOperation.Release;
            lr.lck = lck;
            return(lr);
        }
예제 #7
0
 public static LockRequest ForReleaseObj(ref DbEntry obj) {
   LockRequest lr = new LockRequest();
   lr.op = LockOperation.ReleaseObj;
   lr.obj = obj;
   return lr;
 }
예제 #8
0
 public static LockRequest ForTimeout() {
   LockRequest lr = new LockRequest();
   lr.op = LockOperation.Timeout;
   return lr;
 }
예제 #9
0
 public static LockRequest ForReleaseAll() {
   LockRequest lr = new LockRequest();
   lr.op = LockOperation.ReleaseAll;
   return lr;
 }
예제 #10
0
 public static LockRequest ForRelease(Lock lck) {
   LockRequest lr = new LockRequest();
   lr.op = LockOperation.Release;
   lr.lck = lck;
   return lr;
 }
예제 #11
0
 public static LockRequest ForAcquireWithTimeout(LockMode mode, int timeout, ref DbEntry obj) {
   LockRequest lr =
     new LockRequest(LockOperation.AcquireTimeout, mode, timeout, ref obj, new Lock());
   return lr;
 }
예제 #12
0
 public static LockRequest ForAcquire(LockMode mode, ref DbEntry obj) {
   LockRequest lr =
     new LockRequest(LockOperation.Acquire, mode, 0, ref obj, new Lock());
   return lr;
 }
예제 #13
0
    public void LockVector(int locker, LockFlags flags, LockRequest[] list) {
      DbRetVal ret; 
      int failedIndx;

      // allocate the arguments we need to pass
      DBT* objs = stackalloc DBT[list.Length];
      DB_LOCKREQ* lockReqs = stackalloc DB_LOCKREQ[list.Length];
      // calculate object buffer size and allocate on stack
      int objSize = 0;
      for (int indx = 0; indx < list.Length; indx++)
        objSize += list[indx].Obj.Size;
      byte* objBuf = stackalloc byte[objSize];

      // configure all DB_LOCKREQ instances
      DBT* currObjp = objs;
      byte* currObjBuf = objBuf;
      for (int indx = 0; indx < list.Length; indx++) {
        lockReqs[indx] = list[indx].PrepareLockReq(currObjp, ref currObjBuf);
        currObjp++;
      }

      // perform call into BDB
      lock (rscLock) {
        DB_ENV* evp = CheckDisposed();
        DB_LOCKREQ* lastp;
        ret = evp->LockVector(evp, unchecked((uint)locker), unchecked((UInt32)flags),
          lockReqs, list.Length, out lastp);
        if (ret != DbRetVal.SUCCESS)
          failedIndx = (int)(lastp - lockReqs);
        else
          failedIndx = list.Length;
      }

      // assign the acquired locks back to the initial LockRequest instances
      for (int indx = 0; indx < failedIndx; indx++) {
        LockOperation op = list[indx].Op;
        if (op == LockOperation.Acquire || op == LockOperation.AcquireTimeout)
          list[indx].lck = new Lock(lockReqs[indx].dblock);
      }

      if (ret != DbRetVal.SUCCESS)
        ThrowLockException(ret, failedIndx);
    }