C++ SDL_SemWait函数代码示例

本文整理汇总了C++中SDL_SemWait函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_SemWait函数的具体用法?C++ SDL_SemWait怎么用?C++ SDL_SemWait使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


C++ SDL_SemWait函数代码示例

在下文中一共展示了SDL_SemWait函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: SDL_SemWait

void Enemy::AI(float x, float y)
{
	//SDL_LockMutex(mutex);
	//Sem Lock
	SDL_SemWait(moveLock);
	//std::cout << "AI Lock" << std::endl;

	m_dirX = 0;
	m_dirY = 0;

	if (m_x < x)
	{
		m_dirX = 1;
	}
	else if (m_x > x)
	{
		m_dirX = -1;
	}

	if (m_y < y)
	{
		m_dirY = 1;
	}
	else if (m_y > y)
	{
		m_dirY = -1;
	}

	isColliding(x,y);

	//SDL_UnlockMutex(mutex);
	SDL_SemPost(moveLock);
	//std::cout << "AI Unlock" << std::endl;
}
开发者ID:endaLFC,项目名称:Hackathon-Semaphores,代码行数:34,代码来源:Enemy.cpp

示例2: SDL_mutexP

/* Lock the semaphore */
int
SDL_mutexP(SDL_mutex * mutex)
{
#if SDL_THREADS_DISABLED
    return 0;
#else
    Uint32 this_thread;

    if (mutex == NULL) {
        SDL_SetError("Passed a NULL mutex");
        return -1;
    }

    this_thread = SDL_ThreadID();
    if (mutex->owner == this_thread) {
        ++mutex->recursive;
    } else {
        /* The order of operations is important.
           We set the locking thread id after we obtain the lock
           so unlocks from other threads will fail.
         */
        SDL_SemWait(mutex->sem);
        mutex->owner = this_thread;
        mutex->recursive = 0;
    }

    return 0;
#endif /* SDL_THREADS_DISABLED */
}
开发者ID:Bananattack,项目名称:verge3,代码行数:30,代码来源:SDL_sysmutex.c

示例3: while

int CLoopFeederSink::ThreadMain(void)
{
	while (SDL_SemWait(m_myMsgQueueSemaphore) == 0) {
		CMsg* pMsg = m_myMsgQueue.get_message();

		if (pMsg != NULL) {
			switch (pMsg->get_value()) {
			case MSG_NODE_STOP_THREAD:
				DoStopSink();
				delete pMsg;
				return 0;
			case MSG_NODE_START:
				DoStartSink();
				break;
			case MSG_NODE_STOP:
				DoStopSink();
				break;
			case MSG_SINK_FRAME:
				uint32_t dontcare;
				DoWriteFrame((CMediaFrame*)pMsg->get_message(dontcare));
				break;
			}

			delete pMsg;
		}
	}

	return -1;
}
开发者ID:acassis,项目名称:emlinux-ssd1935,代码行数:29,代码来源:loop_feeder_sink.cpp

示例4: FreeWinding

/*
 * @brief
 */
void FreeWinding(winding_t *w) {

	if (debug)
		SDL_SemWait(semaphores.active_windings);

	Mem_Free(w);
}
开发者ID:EEmmanuel7,项目名称:quetoo,代码行数:10,代码来源:polylib.c

示例5: SDL_CreateSemaphore

void CCamera::init( CameraType cameraType, float X, float Y, float Z, float AspecRatio, float Angle_of_vision ){
    semaphore = SDL_CreateSemaphore( 1 );

    SDL_SemWait( semaphore ); 

    this->cameraType = cameraType; 

    camera_position[0] = X; camera_position[1] = Y; camera_position[2] = Z;
    radius = sqrt( camera_position[0] * camera_position[0] + camera_position[1] * camera_position[1] + camera_position[2] * camera_position[2] );

    x_eye=0.0;  y_eye=0.0;  z_eye=0.0;
    up_vector[0] = 0.0; up_vector[1] = 0.0; up_vector[2] = 1.0;
    axle_vector[0] = 1.0;  axle_vector[1] = 0.0; axle_vector[2] = 0.0;

    const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo( ); 
    float GW = vidInfo->current_w; 
    float GH = vidInfo->current_h; 
    vp_x1 = 0.0; 	vp_x2 = GW;
    vp_y1 = 0.0; 	vp_y2 = GH;

    angle_of_vision = Angle_of_vision;
    this->aspecRatio=AspecRatio;

    redraw = true;

    SDL_SemPost( semaphore ); 

    return;
}
开发者ID:cosmiczilch,项目名称:AirHockey,代码行数:29,代码来源:ccamera.cpp

示例6: SDL_SemWaitTimeout

int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
{
    int retval;

    if ( ! sem ) {
        SDL_SetError("Passed a NULL semaphore");
        return -1;
    }

    /* Try the easy cases first */
    if ( timeout == 0 ) {
        return SDL_SemTryWait(sem);
    }
    if ( timeout == SDL_MUTEX_MAXWAIT ) {
        return SDL_SemWait(sem);
    }

    /* Ack!  We have to busy wait... */
    timeout += SDL_GetTicks();
    do {
        retval = SDL_SemTryWait(sem);
        if ( retval == 0 ) {
            break;
        }
        SDL_Delay(1);
    } while ( SDL_GetTicks() < timeout );

    return retval;
}
开发者ID:luislasonbra,项目名称:bennugd-wii,代码行数:29,代码来源:SDL_syssem.c

示例7: SDL_SemWait

void CCamera::sidewind( int direction, float amount ) {
    SDL_SemWait( semaphore ); 

    switch( direction ) {
    	case UP :
		camera_position[2] += amount;
		z_eye += amount;
		break;

    	case DOWN :
		camera_position[2] -= amount;
		z_eye -= amount;
		break;

    	case LEFT :
		camera_position[0] -= amount;
		x_eye -= amount;
		break;

    	case RIGHT :
		camera_position[0] += amount;
		x_eye += amount;
		break;

    }
	
    redraw = true;
    SDL_SemPost( semaphore ); 

    return;
}
开发者ID:cosmiczilch,项目名称:AirHockey,代码行数:31,代码来源:ccamera.cpp

示例8: while

void Sync_Audio::write( const sample_t* in, int remain )
{
	while ( remain )
	{
		int count = buf_size - write_pos;
		if ( count > remain )
			count = remain;
		
		sample_t* out = buf( write_buf ) + write_pos;
		if ( gain != (1L << gain_bits) )
		{
			register long gain = this->gain;
			for ( int n = count; n--; )
				*out++ = (*in++ * gain) >> gain_bits;
		}
		else
		{
			memcpy( out, in, count * sizeof (sample_t) );
			in += count;
		}
		
		write_pos += count;
		remain -= count;
		
		if ( write_pos >= buf_size )
		{
			write_pos = 0;
			write_buf = (write_buf + 1) % buf_count;
			SDL_SemWait( free_sem );
		}
	}
开发者ID:Drenn1,项目名称:GameYob,代码行数:31,代码来源:Sync_Audio.cpp

示例9: SDL_CondBroadcast

/* Restart all threads that are waiting on the condition variable */
int SDL_CondBroadcast(SDL_cond *cond)
{
	if ( ! cond ) {
		SDL_SetError("Passed a NULL condition variable");
		return -1;
	}

	/* If there are waiting threads not already signalled, then
	   signal the condition and wait for the thread to respond.
	*/
	SDL_LockMutex(cond->lock);
	if ( cond->waiting > cond->signals ) {
		int i, num_waiting;

		num_waiting = (cond->waiting - cond->signals);
		cond->signals = cond->waiting;
		for ( i=0; i<num_waiting; ++i ) {
			SDL_SemPost(cond->wait_sem);
		}
		/* Now all released threads are blocked here, waiting for us.
		   Collect them all (and win fabulous prizes!) :-)
		 */
		SDL_UnlockMutex(cond->lock);
		for ( i=0; i<num_waiting; ++i ) {
			SDL_SemWait(cond->wait_done);
		}
	} else {
		SDL_UnlockMutex(cond->lock);
	}

	return 0;
}
开发者ID:OS2World,项目名称:LIB-SDL,代码行数:33,代码来源:SDL_syscond.c

示例10: XAUDIO2_WaitDevice

static void
XAUDIO2_WaitDevice(_THIS)
{
    if (this->enabled) {
        SDL_SemWait(this->hidden->semaphore);
    }
}
开发者ID:Iced-Tea,项目名称:milton,代码行数:7,代码来源:SDL_xaudio2.c

示例11: SDL_SemWait

void SoundSDL::read(u16 * stream, int length)
{
	if (!_initialized || length <= 0 || !emulating)
		return;

#if !JS
	/* since this is running in a different thread, speedup and
	 * throttle can change at any time; save the value so locks
	 * stay in sync */
	bool lock = (emulating && !speedup) ? true : false;

	if (lock)
		SDL_SemWait (_semBufferFull);

	SDL_mutexP(_mutex);
#endif

	_rbuf.read(stream, std::min(static_cast<std::size_t>(length) / 2, _rbuf.used()));

#if !JS
	SDL_mutexV(_mutex);

	SDL_SemPost (_semBufferEmpty);
#endif
}
开发者ID:akerl,项目名称:demos,代码行数:25,代码来源:SoundSDL.cpp

示例12: resolverloop

int resolverloop(void * data)
{
    resolverthread *rt = (resolverthread *)data;
    for(;;)
    {
        SDL_SemWait(resolversem);
        SDL_LockMutex(resolvermutex);
        if(resolverqueries.empty())
        {
            SDL_UnlockMutex(resolvermutex);
            continue;
        }
        rt->query = resolverqueries.pop();
        rt->starttime = lastmillis;
        SDL_UnlockMutex(resolvermutex);
        ENetAddress address = { ENET_HOST_ANY, CUBE_SERVINFO_PORT };
        enet_address_set_host(&address, rt->query);
        SDL_LockMutex(resolvermutex);
        resolverresult &rr = resolverresults.add();
        rr.query = rt->query;
        rr.address = address;
        rt->query = NULL;
        rt->starttime = 0;
        SDL_UnlockMutex(resolvermutex);
    };
    return 0;
};
开发者ID:Knapsack44,项目名称:w,代码行数:27,代码来源:serverbrowser.cpp

示例13: display_put_wait

void display_put_wait( const char *orig_str )
{
    display_put( orig_str );

    SDLMod key_mod = SDL_GetModState();
    if ( !(key_mod & KMOD_CTRL) )
        SDL_SemWait( key_sem );
}
开发者ID:LasDesu,项目名称:openbgi-hl,代码行数:8,代码来源:main.c

示例14: SDL_SemWait

void BXBGJob::Lock() 
{
	if (!m_bActive) 
  {
		//LOG(LOG_LEVEL_DEBUG,"PAUSE: Background job locked id = %d", GetId());
		SDL_SemWait(m_pJobLock);
	}
}
开发者ID:flyingtime,项目名称:boxee,代码行数:8,代码来源:bxbgprocess.cpp

示例15: SDL_SemWait

void RegionViewer::incNumPainted()
{
	SDL_SemWait(m_lock);
	
	m_numPainted += 1;
	
	SDL_SemPost(m_lock);
}
开发者ID:kotrenn,项目名称:ogam,代码行数:8,代码来源:regionviewer.cpp

本文标签属性:

示例:示例的拼音

代码:代码转换器

SDL_SemWait:SDL_SemWait

上一篇:银川是哪个省的(银川市属于哪个省)(银川市属于哪个省)
下一篇:万宁市在哪个省(万宁哪些城市有)(万宁市在哪个城市)

为您推荐