Ejemplo n.º 1
0
int main()
{		
	struct point p;
	p.x = p.y = p.z = 1;
	int i = 0;
	for(; i < 1000; ++i)
	{
		g_points[i] = create_atomic_type(sizeof(p));
		SetPoint(g_points[i],p);
	}
	thread_t t1 = CREATE_THREAD_RUN(1,SetRotine,NULL);
	thread_t t2 = CREATE_THREAD_RUN(1,GetRoutine,(void*)1);	
	thread_t t3 = CREATE_THREAD_RUN(1,GetRoutine,(void*)2);	
	thread_t t4 = CREATE_THREAD_RUN(1,GetRoutine,(void*)3);	
	uint32_t tick = GetSystemMs();
	while(1)
	{
		uint32_t new_tick = GetSystemMs();
		if(new_tick - tick >= 1000)
		{
			printf("get:%d,set:%d,miss:%d\n",get_count,set_count,miss_count);
			get_count = set_count = miss_count = 0;
			tick = new_tick;
		}
		sleepms(50);
	}
}
Ejemplo n.º 2
0
void init_system_time(uint32_t sleep_time)
{
	if(stm == NULL)
	{
		stm = calloc(1,sizeof(*stm));
		stm->current_index = 1;
		stm->sleep_time = sleep_time;
		_update();
		_update();
		CREATE_THREAD_RUN(0,_thread_routine,NULL);
	}
}
Ejemplo n.º 3
0
int main()
{
	//thread_run(routine,0);	
	//getchar();
	//thread_t t = CREATE_THREAD_RUN(1,routine,0);
	//join(t);
	barrior_t b = barrior_create(10);
	int i = 0;
	for(i;i < 10; ++i)
		CREATE_THREAD_RUN(1,routine,(void*)b);
	getchar();
	barrior_destroy(&b);
	return 0;
}
Ejemplo n.º 4
0
int32_t	init_log_system()
{
	if(!g_log_system)
	{
		g_log_system = calloc(1,sizeof(*g_log_system));
		g_log_system->mtx = mutex_create();
		g_log_system->is_close = 0;
		g_log_system->log_files = create_link_list();
		g_log_system->worker_thread = CREATE_THREAD_RUN(1,worker_routine,0);
		g_log_system->last_tick = GetSystemMs();
		g_log_system->bytes = 0;
		g_log_system->_wpacket_allocator = NULL;
		return 0;
	}
	return -1;
}