dllserver.cpp

来自「firtext搜索引擎源码」· C++ 代码 · 共 29 行

CPP
29
字号
#include "com/Com.h"
#include "com/comerror.h"
#include <assert.h>
#include <pthread.h>

static int32_t volatile lock_count = 0;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

FX_WINOLEAPI firtex::com::DllCanUnloadNowImpl()
{
	pthread_mutex_lock( &mutex );
	assert( lock_count >= 0 );
	int32_t tmp = lock_count;
	pthread_mutex_unlock( &mutex );

	return ( tmp > 0 ) ? FX_S_FALSE : FX_S_OK;
}

FX_WINOLEAPI firtex::com::DllLockServerImpl( int32_t fLock )
{
	pthread_mutex_lock( &mutex );
	assert( fLock || lock_count>0 );
	lock_count += fLock ? 1 : -1;
	assert( !fLock || lock_count>0 );
	pthread_mutex_unlock( &mutex );

	return FX_S_OK;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?