当前位置: 首页>>代码示例>>C++>>正文


C++ EncFS_Context::openFileCount方法代码示例

本文整理汇总了C++中EncFS_Context::openFileCount方法的典型用法代码示例。如果您正苦于以下问题:C++ EncFS_Context::openFileCount方法的具体用法?C++ EncFS_Context::openFileCount怎么用?C++ EncFS_Context::openFileCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EncFS_Context的用法示例。


在下文中一共展示了EncFS_Context::openFileCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: idleMonitor

static
void * idleMonitor(void *_arg)
{
  EncFS_Context *ctx = (EncFS_Context*)_arg;
  shared_ptr<EncFS_Args> arg = ctx->args;

  const int timeoutCycles = 60 * arg->idleTimeout / ActivityCheckInterval;
  int idleCycles = 0;

  ctx->wakeupMutex.lock();

  while(ctx->running)
  {
    int usage = ctx->getAndResetUsageCounter();

    if(usage == 0 && ctx->isMounted())
      ++idleCycles;
    else
      idleCycles = 0;

    if(idleCycles >= timeoutCycles)
    {
      int openCount = ctx->openFileCount();
      if( openCount == 0 && unmountFS( ctx ) )
      {
#ifdef CMAKE_USE_PTHREADS_INIT
        // wait for main thread to wake us up
        pthread_cond_wait( &ctx->wakeupCond, &ctx->wakeupMutex._mutex );
#endif
        break;
      }

      VLOG(1) << "num open files: " << openCount;
    }

    VLOG(1) << "idle cycle count: " << idleCycles 
      << ", timeout after " << timeoutCycles;

    struct timeval currentTime;
    gettimeofday( &currentTime, 0 );
    struct timespec wakeupTime;
    wakeupTime.tv_sec = currentTime.tv_sec + ActivityCheckInterval;
    wakeupTime.tv_nsec = currentTime.tv_usec * 1000;
#ifdef CMAKE_USE_PTHREADS_INIT
    pthread_cond_timedwait( &ctx->wakeupCond, 
        &ctx->wakeupMutex._mutex, &wakeupTime );
#endif
  }

  ctx->wakeupMutex.unlock();

  VLOG(1) << "Idle monitoring thread exiting";

  return 0;
}
开发者ID:bentolor,项目名称:encfs,代码行数:55,代码来源:main.cpp

示例2: idleMonitor

static
void * idleMonitor(void *_arg)
{
    EncFS_Context *ctx = (EncFS_Context*)_arg;
    shared_ptr<EncFS_Args> arg = ctx->args;

    const int timeoutCycles = 60 * arg->idleTimeout / ActivityCheckInterval;
    int idleCycles = 0;

    pthread_mutex_lock( &ctx->wakeupMutex );
    
    while(ctx->running)
    {
	int usage = ctx->getAndResetUsageCounter();

	if(usage == 0 && ctx->isMounted())
	    ++idleCycles;
	else
	    idleCycles = 0;
	
	if(idleCycles >= timeoutCycles)
	{
	    int openCount = ctx->openFileCount();
	    if( openCount == 0 && unmountFS( ctx ) )
	    {
		// wait for main thread to wake us up
		pthread_cond_wait( &ctx->wakeupCond, &ctx->wakeupMutex );
		break;
	    }
		
	    rDebug("num open files: %i", openCount );
	}
	    
	rDebug("idle cycle count: %i, timeout after %i", idleCycles,
		timeoutCycles);

	struct timeval currentTime;
	gettimeofday( &currentTime, 0 );
	struct timespec wakeupTime;
	wakeupTime.tv_sec = currentTime.tv_sec + ActivityCheckInterval;
	wakeupTime.tv_nsec = currentTime.tv_usec * 1000;
	pthread_cond_timedwait( &ctx->wakeupCond, 
		&ctx->wakeupMutex, &wakeupTime );
    }
    
    pthread_mutex_unlock( &ctx->wakeupMutex );

    rDebug("Idle monitoring thread exiting");

    return 0;
}
开发者ID:ghostbar,项目名称:encfs.deb,代码行数:51,代码来源:main.cpp


注:本文中的EncFS_Context::openFileCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。