Example #1
0
int main(int argc, char ** argv)
{
	os_thread_t hThreadTcp,hThreadUdp;
	unsigned int Tcpid, Udpid;
	if(argc !=2)
	{
		printf("please input the parameters!!");
		exit(1);
	}
	
	os_thread_begin(&hThreadUdp, UdpThreadFunc, &Udpid);
	os_thread_begin(&hThreadTcp, TcpThreadFunc, &Tcpid);

	printf("udp listen thread start sucess!!\n");
	os_thread_wait(hThreadUdp, NULL);
	os_thread_close(hThreadUdp);

	printf("tcp listen thread start sucess!!\n");
	os_thread_wait(hThreadTcp, NULL);
	os_thread_close(hThreadTcp);

	return 0;
}
Example #2
0
void client_do()
{
	int i;

	for(i=0; i<sizeof(tids)/sizeof(tids[0]); i++) {
		os_thread_begin(&tids[i], client_thread_proc, NULL);
	}

	getchar();
	quit_flag = 1;

	for(i=0; i<sizeof(tids)/sizeof(tids[0]); i++) {
		os_thread_wait(tids[i], NULL);
	}
}
Example #3
0
void destroy_engine( CNetEngine *pEngine )
{
	if ( pEngine )
	{
		pEngine->iIsRunning = 0;
		os_thread_wait( pEngine->pEngineThread );
		
		//close epoll or kqueue id.
		close( pEngine->iEngineId );
		pEngine->iEngineId = -1;
				
		//release memory.		
		mem_free( pEngine );
		pEngine = NULL;
	}
}
Example #4
0
int log_close(LOG_HANDLE ctx)
{
	int ret;

	if(ctx->stream.buf!=NULL) {
		os_sem_post(&ctx->stream.inque);
		os_thread_wait(ctx->stream.thread, NULL);

		os_sem_destroy(&ctx->stream.inque);
		os_sem_destroy(&ctx->stream.ouque);
		os_mutex_destroy(&ctx->stream.mtx);
	}

	ret = map[ctx->type].func_close(ctx);
	free(ctx);
	return ret;
}