예제 #1
0
파일: main.cpp 프로젝트: khiemnv/algorithms
void test_explorer()
{
#define TEST_EXPORT
#define TEST_THREADS
  enum {
    queueBufferSize = 4096*8,
  };
  char queueBuffer[queueBufferSize];
  TransportParams* pParams;
  Transporter transporter;
  pParams = transporter.TransportDataInit(
#ifdef TEST_EXPORT
    TRUE,
#else
    FALSE,            //importMode
#endif
    queueBuffer,
    queueBufferSize,
    FS_FILE_SWAP,
#ifdef TEST_EXPORT
    MULTI_PATHS_ZEXPORT
#else
    MULTI_PATHS_ZIMPPORT
#endif
    );
  transporter.Init(pParams);
#ifdef TEST_THREADS
  transporter.Start();
  for (;;) {
    TransportStatus status;
    transporter.GetStatus(&status);
    _tprintf(TEXT("status %d expl %I64d xpot %I64d\n"), status.stateFlags, status.exploredSize, status.xportedSize);
    if (status.stateFlags & TransportStatus::xportingComplete)
      break;
    Sleep(500);
  }
#else //TEST_THREADS
#ifdef TEST_EXPORT
  transporter.ExploreThreadMain();
  transporter.XportThreadMain();
#else
  transporter.XportThreadMain();
#endif
#endif //TEST_THREADS
  transporter.Final();
  transporter.TransportDataFinal(pParams);
}
예제 #2
0
파일: main.cpp 프로젝트: khiemnv/algorithms
//<export/import> [zParams]
void shell_xpot(int argc, TCHAR* argv[])
{
  int rc;
  int nDone = 0;
  int isExport = 0;
  TCHAR* zParams;
  TCHAR zSwapFile[MAX_PATH];

  enum {
    queueBufferSize = 4096*8,
  };
  char queueBuffer[queueBufferSize];
  TransportParams* pParams;
  Transporter transporter;

  do {
    //(1) get input args
    if (argc < 2) break;
    if (_tcscmp(argv[1], TEXT("export")) == 0) {
      zParams = MULTI_PATHS_ZEXPORT;
      isExport = TRUE;
    }
    else if (_tcscmp(argv[1], TEXT("import")) == 0) {
      zParams = MULTI_PATHS_ZIMPPORT;
      isExport = FALSE;
    } else
      break;
    if (argc == 3) zParams = argv[2];
    nDone = 1;
    //(2) init params
    GetModuleDir(zSwapFile, MAX_PATH);
    pathMng path;
    path.pathPush(zSwapFile, MAX_PATH, TEXT("\\fs.bin"));
    pParams = transporter.TransportDataInit(
      isExport,
      queueBuffer,
      queueBufferSize,
      zSwapFile,
      zParams
      );
    rc = transporter.Init(pParams);
    if (rc) break;
    transporter.Start();
    for (int i = 0;;i++) {
      TransportStatus status;
      transporter.GetStatus(&status);
      _tprintf(TEXT("status %d expl %I64d xpot %I64d\n"), status.stateFlags, status.exploredSize, status.xportedSize);
      if (status.stateFlags & TransportStatus::xportingComplete)
        break;
#if (1)
      Sleep(500);
#else //test interrupt
      Sleep(50);
      if (i==1) {
        transporter.Cancel();
      }
#endif
    }
    transporter.Final();
    nDone = 2;
  } while(FALSE);

  switch (nDone) {
    case 2:
      break;
    case 1:
      _tprintf(TEXT("init fail\n"));
      break;
    default:
      assert(nDone == 0);
      _tprintf(TEXT("<export/import> [zParams]\n"));
      break;
  }
}