⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testlockht.c

📁 用c/c++实现的一个CMPP API
💻 C
字号:
#include "apilockht.h"#define DPrintf printfpthread_t tid1, tid2;void	*thread1( void* ), *thread2( void* );static  recBufFd g_BufFd;#define REPEATNUM 1int main( int argc, char** argv ){	int	nRet;	        nRet = nLockInitMemHT( 10, 20, 1, 1024,                           &g_BufFd );	DPrintf( "nRet = %d, after nLockInitMemHT\n ", nRet  );		nRet = pthread_create( &tid1, NULL, thread1, NULL );	DPrintf( "nRet = %d, after creat thread1 \n", nRet  );		pthread_create( &tid2, NULL, thread2, NULL );	DPrintf( "nRet = %d, after thread2 creat\n ", nRet  );		pthread_join( tid1, NULL );	pthread_join( tid2, NULL );			return 0;	}void *thread1( void* arg ){	char sKey[10];	char sPck[20];	int nCellNum;	int nLoad;	int i;	int nRet;		memset( sKey, 0, 10 );	strcpy( sKey, "012345" );		memset( sPck, 0, 20 );	strcpy( sPck, "0123456789" );			//nMemHTDisp( g_RecMemHTFD );	for( i=0; i<REPEATNUM; i++ )	{		nRet = nLockAddACell( &g_BufFd, sKey, 10, sPck, 20 );		DPrintf( "nRet = %d after add cell\n", nRet );	}		nLoad = 	nLockGetHTLoad( &g_BufFd, &nCellNum );	DPrintf( "nCellNum = %d, nLoad = %d\n", nCellNum, nLoad );						return ( NULL );}void *thread2( void* arg ){	char sKey[10];	char sPck[20];	int nCellNum;	int nLoad;	int i;	int nRet;		memset( sKey, 0, 10 );	strcpy( sKey, "012345" );		memset( sPck, 0, 20 );	//strcpy( sPck, "0123456789" );				sleep( 1 );	for( i=0; i<REPEATNUM; i++ )	{        //memset( sKey, 0, 10 );            	DPrintf( "before lock read\n" );    	nRet = nLockDelACell( &g_BufFd, sKey, 10, sPck, 20 );    	DPrintf( "nRet = %d,after read\n", nRet );    	DPrintf( "sKey=%s\n", sKey );	}	nLoad = 	nLockGetHTLoad( &g_BufFd, &nCellNum );	DPrintf( "after Read, nCellNum = %d, nLoad = %d\n", nCellNum, nLoad );		return ( NULL );}

⌨️ 快捷键说明

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