Exemplo n.º 1
0
rdpChanMan *
freerdp_chanman_new(void)
{
	rdpChanMan * chan_man;
	rdpChanManList * list;

	chan_man = (rdpChanMan *) malloc(sizeof(rdpChanMan));
	memset(chan_man, 0, sizeof(rdpChanMan));

	SEMAPHORE_INIT(chan_man->sem, 0, 1); /* start at 1 */
	SEMAPHORE_INIT(chan_man->sem_event, 0, 1); /* start at 1 */
#ifdef _WIN32
	chan_man->chan_event = CreateEvent(NULL, TRUE, FALSE, NULL);
#else
	chan_man->pipe_fd[0] = -1;
	chan_man->pipe_fd[1] = -1;
	if (pipe(chan_man->pipe_fd) < 0)
	{
		DEBUG_CHANMAN("freerdp_chanman_init: pipe failed");
	}
#endif

	/* Add it to the global list */
	list = (rdpChanManList *) malloc(sizeof(rdpChanManList));
	list->chan_man = chan_man;

	MUTEX_LOCK(g_mutex_list);
	list->next = g_chan_man_list;
	g_chan_man_list = list;
	MUTEX_UNLOCK(g_mutex_list);

	return chan_man;
}
Exemplo n.º 2
0
//
// I_SelectTimer
// Sets up the timer function based on if we can use signals for efficent CPU
// usage.
//
void I_SelectTimer()
{
	SEMAPHORE_INIT(timerWait, 0, 0)
#ifndef __sun
	signal(SIGALRM, I_HandleAlarm);
#else
	struct sigaction alrmaction;
	sigaction(SIGALRM, NULL, &alrmaction);
	alrmaction.sa_handler = I_HandleAlarm;
	sigaction(SIGALRM, &alrmaction, NULL);
#endif

	struct itimerval itv;
	itv.it_interval.tv_sec = itv.it_value.tv_sec = 0;
	itv.it_interval.tv_usec = itv.it_value.tv_usec = 1000000/TICRATE;

	if (setitimer(ITIMER_REAL, &itv, NULL) != 0)
	{
		I_GetTime = I_GetTimePolled;
		I_FreezeTime = I_FreezeTimePolled;
		I_WaitForTic = I_WaitForTicPolled;
	}
	else
	{
		I_GetTime = I_GetTimeSignaled;
		I_FreezeTime = I_FreezeTimeSignaled;
		I_WaitForTic = I_WaitForTicSignaled;
	}
}
Exemplo n.º 3
0
void _ml_cbr_init() {
    ASSERT(!initialized);
    ASSERT(cbr_node_pool == NULL);
    ASSERT(cbr_record_pool == NULL);
    ASSERT(ml_cbr_lock == NULL);
    cbr_node_pool = create_node_arena();
    cbr_record_pool = create_record_arena();
    SEMAPHORE_INIT(ml_cbr_lock);
    initialized = 1;
}