示例#1
0
FrameViewRequestLocker::FrameViewRequestLocker(const FrameViewRequestPtr& request, bool doLock)
: request(request)
, locked(false)
{
    if (doLock) {
        lockRequest();
    }
}
示例#2
0
/**
 * @brief: random test 2, unoverlapped range lock and unlock
 *
 */
void random_test2(){
  int i, j;
 
  for(j = 0; j < 2; j++){
    treeInit();
  
    /*
     *to check the lock
     */
    for(i = 0; i < MAX_NODES; i++){
      unsigned start_lba = i*5;
      unsigned end_lba   = start_lba + 4;
      unsigned type      = rand()%2;
      lockRequest(start_lba, end_lba, type, 1, 0);
    }
  
    //treeDump(rootArray[0]);

    /*
     *to check the unlock
     */
    for(i = 0; i < MAX_NODES -2; i++){
      printf("\n\ndeleting case %d with", i+ 1);
      int index = (MAX_NODES - i - 1);
      printf("  event index %d\n", nodes[index].eventIndex);
      lockRelease(&nodes[index], 0);
    }
     treeDump(rootArray[0]);

    /*
     *to check the index overflow
     */
    for(i = 0; i < MAX_NODES; i++){
      unsigned start_lba = i*5;
      unsigned end_lba   = start_lba + 4;
      unsigned type      = rand()%2;
      lockRequest(start_lba, end_lba, type, 1, 0);
      treeDump(rootArray[0]);
    }
    printf("\n");
  }
}