本文整理汇总了C++中SDL_CreateCond函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_CreateCond函数的具体用法?C++ SDL_CreateCond怎么用?C++ SDL_CreateCond使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_CreateCond函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SDL_CreateMutex
TaskManager::TaskManager() {
quitSignal = false;
mutex = SDL_CreateMutex();
taskFinished = SDL_CreateCond();
queueThreadWakeup = SDL_CreateCond();
struct QueuedTaskHandler : Action {
TaskManager* manager;
QueuedTaskHandler(TaskManager* m) : manager(m) {}
int handle() {
ScopedLock lock(manager->mutex);
while(true) {
if(manager->queuedTasks.size() > 0) {
Action* act = manager->queuedTasks.front();
manager->queuedTasks.pop_front();
SDL_mutexV(manager->mutex);
act->handle();
delete act;
SDL_mutexP(manager->mutex);
continue;
}
if(manager->quitSignal) {
return 0;
}
SDL_CondWait(manager->queueThreadWakeup, manager->mutex);
}
}
};
queueThread = threadPool->start(new QueuedTaskHandler(this), "queued task handler");
}
示例2: SDL_ANDROID_MultiThreadedVideoLoopInit
void SDL_ANDROID_MultiThreadedVideoLoopInit()
{
videoThread.mutex = SDL_CreateMutex();
videoThread.cond = SDL_CreateCond();
videoThread.cond2 = SDL_CreateCond();
videoThread.execute = 0;
}
示例3: socket_thread_start
/**
* Initialize and start up the worker threads.
*/
void socket_thread_start(void)
{
if (input_buffer_cond == NULL) {
input_buffer_cond = SDL_CreateCond();
input_buffer_mutex = SDL_CreateMutex();
output_buffer_cond = SDL_CreateCond();
output_buffer_mutex = SDL_CreateMutex();
socket_mutex = SDL_CreateMutex();
}
abort_thread = 0;
input_thread = SDL_CreateThread(reader_thread_loop, NULL);
if (input_thread == NULL) {
LOG(ERROR, "Unable to start socket thread: %s", SDL_GetError());
exit(1);
}
output_thread = SDL_CreateThread(writer_thread_loop, NULL);
if (output_thread == NULL) {
LOG(ERROR, "Unable to start socket thread: %s", SDL_GetError());
exit(1);
}
}
示例4: SDL_CreateMutex
void ThreadPool::init(int _numThreads)
{
//setup mutex
quequeMutex = SDL_CreateMutex();
workerMutex = SDL_CreateMutex();
condHaveWork = SDL_CreateCond();
mutexBarrier = SDL_CreateMutex();
condBarrier = SDL_CreateCond();
//setup number of threads
numThreads = _numThreads;
//initialize all threads
for(int i = 0; i < numThreads; i++)
{
char threadName[128];
sprintf(threadName,"Thread %d",i);
//Create thread
threads[i] = SDL_CreateThread(worker,threadName,&poolThread);
if (NULL == threads[i])
{
printf ("Falha ao Criar thread \n");
}
}
}
示例5: sim_kernel_init
static bool sim_kernel_init(void)
{
sim_irq_mtx = SDL_CreateMutex();
if (sim_irq_mtx == NULL)
{
panicf("Cannot create sim_handler_mtx\n");
return false;
}
sim_thread_cond = SDL_CreateCond();
if (sim_thread_cond == NULL)
{
panicf("Cannot create sim_thread_cond\n");
return false;
}
#ifndef HAVE_SDL_THREADS
wfi_cond = SDL_CreateCond();
if (wfi_cond == NULL)
{
panicf("Cannot create wfi\n");
return false;
}
wfi_mutex = SDL_CreateMutex();
if (wfi_mutex == NULL)
{
panicf("Cannot create wfi mutex\n");
return false;
}
#endif
return true;
}
示例6: GLimp_SpawnRenderThread
/*
===============
GLimp_SpawnRenderThread
===============
*/
qboolean GLimp_SpawnRenderThread( void ( *function )( void ) )
{
static qboolean warned = qfalse;
if ( !warned )
{
Com_Printf( "WARNING: You enable r_smp at your own risk!\n" );
warned = qtrue;
}
#if !defined( MACOS_X ) && !defined( WIN32 ) && !defined ( SDL_VIDEO_DRIVER_X11 ) && !SDL_VERSION_ATLEAST( 2, 0, 0 )
return qfalse; /* better safe than sorry for now. */
#endif
if ( renderThread != NULL ) /* hopefully just a zombie at this point... */
{
Com_Printf( "Already a render thread? Trying to clean it up...\n" );
GLimp_ShutdownRenderThread();
}
smpMutex = SDL_CreateMutex();
if ( smpMutex == NULL )
{
Com_Printf( "smpMutex creation failed: %s\n", SDL_GetError() );
GLimp_ShutdownRenderThread();
return qfalse;
}
renderCommandsEvent = SDL_CreateCond();
if ( renderCommandsEvent == NULL )
{
Com_Printf( "renderCommandsEvent creation failed: %s\n", SDL_GetError() );
GLimp_ShutdownRenderThread();
return qfalse;
}
renderCompletedEvent = SDL_CreateCond();
if ( renderCompletedEvent == NULL )
{
Com_Printf( "renderCompletedEvent creation failed: %s\n", SDL_GetError() );
GLimp_ShutdownRenderThread();
return qfalse;
}
renderThreadFunction = function;
renderThread = SDL_CreateThread( GLimp_RenderThreadWrapper, "render thread", NULL );
if ( renderThread == NULL )
{
ri.Printf( PRINT_ALL, "SDL_CreateThread() returned %s\n", SDL_GetError() );
GLimp_ShutdownRenderThread();
return qfalse;
}
return qtrue;
}
示例7: GLimp_SpawnRenderThread
/*
===============
GLimp_SpawnRenderThread
===============
*/
qboolean GLimp_SpawnRenderThread(void (*function)(void))
{
if (renderThread == (void *)0xdead)
{
Com_Printf("SMP: Not safe restarting thread.\n");
renderThread = NULL;
return qfalse;
}
if (renderThread != NULL)
{
Com_Printf("SMP: Render thread still Running.\n");
return qtrue;
}
smpData = (void *)0xdead;
smpMutex = SDL_CreateMutex();
if (!smpMutex)
{
Com_Printf("SMP: Mutex creation failed: %s\n", SDL_GetError());
GLimp_ShutdownRenderThread();
return qfalse;
}
renderCommandsEvent = SDL_CreateCond();
if (renderCommandsEvent == NULL)
{
Com_Printf("SMP: CommandEvent creation failed: %s\n", SDL_GetError());
GLimp_ShutdownRenderThread();
return qfalse;
}
renderCompletedEvent = SDL_CreateCond();
if (renderCompletedEvent == NULL)
{
Com_Printf("SMP: CompletedEvent creation failed: %s\n", SDL_GetError());
GLimp_ShutdownRenderThread();
return qfalse;
}
glimpRenderThread = function;
renderThread = SDL_CreateThread(GLimp_RenderThreadWrapper, GLthreadname);
if (renderThread == NULL)
{
ri.Printf(PRINT_ALL, "SDL: CreateThread() returned %s", SDL_GetError());
GLimp_ShutdownRenderThread();
return qfalse;
}
SDL_LockMutex(smpMutex);
while ( smpData )
SDL_CondWait(renderCompletedEvent, smpMutex);
SDL_UnlockMutex(smpMutex);
return qtrue;
}
示例8: SDL_AMediaCodec_FakeFifo_init
sdl_amedia_status_t SDL_AMediaCodec_FakeFifo_init(SDL_AMediaCodec_FakeFifo *fifo)
{
memset(fifo, 0, sizeof(SDL_AMediaCodec_FakeFifo));
fifo->mutex = SDL_CreateMutex();
fifo->wakeup_enqueue_cond = SDL_CreateCond();
fifo->wakeup_dequeue_cond = SDL_CreateCond();
return SDL_AMEDIA_OK;
}
示例9: ThreadPoolItem
void ThreadPool::prepareNewThread() {
ThreadPoolItem* t = new ThreadPoolItem();
t->pool = this;
t->finishedSignal = SDL_CreateCond();
t->readyForNewWork = SDL_CreateCond();
t->finished = false;
t->working = false;
availableThreads.insert(t);
t->thread = SDL_CreateThread(threadWrapper, t);
}
示例10: GLimp_SpawnRenderThread
/*
===============
GLimp_SpawnRenderThread
===============
*/
bool GLimp_SpawnRenderThread( void ( *function )() )
{
static bool warned = false;
if ( !warned )
{
Com_Printf( "WARNING: You enable r_smp at your own risk!\n" );
warned = true;
}
if ( renderThread != nullptr ) /* hopefully just a zombie at this point... */
{
Com_Printf( "Already a render thread? Trying to clean it up...\n" );
GLimp_ShutdownRenderThread();
}
smpMutex = SDL_CreateMutex();
if ( smpMutex == nullptr )
{
Com_Printf( "smpMutex creation failed: %s\n", SDL_GetError() );
GLimp_ShutdownRenderThread();
return false;
}
renderCommandsEvent = SDL_CreateCond();
if ( renderCommandsEvent == nullptr )
{
Com_Printf( "renderCommandsEvent creation failed: %s\n", SDL_GetError() );
GLimp_ShutdownRenderThread();
return false;
}
renderCompletedEvent = SDL_CreateCond();
if ( renderCompletedEvent == nullptr )
{
Com_Printf( "renderCompletedEvent creation failed: %s\n", SDL_GetError() );
GLimp_ShutdownRenderThread();
return false;
}
renderThreadFunction = function;
renderThread = SDL_CreateThread( GLimp_RenderThreadWrapper, "render thread", nullptr );
if ( renderThread == nullptr )
{
ri.Printf( PRINT_ALL, "SDL_CreateThread() returned %s\n", SDL_GetError() );
GLimp_ShutdownRenderThread();
return false;
}
return true;
}
示例11: SDL_CreateMutex
ThreadPool::ThreadPool(unsigned int size) {
nextAction = NULL; nextIsHeadless = false; nextData = NULL;
quitting = false;
mutex = SDL_CreateMutex();
awakeThread = SDL_CreateCond();
threadStartedWork = SDL_CreateCond();
threadStatusChanged = SDL_CreateCond();
startMutex = SDL_CreateMutex();
notes << "ThreadPool: creating " << size << " threads ..." << endl;
while(availableThreads.size() < size)
prepareNewThread();
}
示例12: Sys_InitThreads
/*
==================
Sys_InitThreads
==================
*/
void Sys_InitThreads() {
// critical sections
for (int i = 0; i < MAX_CRITICAL_SECTIONS; i++) {
mutex[i] = SDL_CreateMutex();
if (!mutex[i]) {
Sys_Printf("ERROR: SDL_CreateMutex failed\n");
return;
}
}
// events
for (int i = 0; i < MAX_TRIGGER_EVENTS; i++) {
cond[i] = SDL_CreateCond();
if (!cond[i]) {
Sys_Printf("ERROR: SDL_CreateCond failed\n");
return;
}
signaled[i] = false;
waiting[i] = false;
}
// threads
for (int i = 0; i < MAX_THREADS; i++)
thread[i] = NULL;
thread_count = 0;
}
示例13: midi_engine_start
int midi_engine_start(void)
{
if (_connected)
return 1;
midi_mutex = SDL_CreateMutex();
midi_record_mutex = SDL_CreateMutex();
midi_play_mutex = SDL_CreateMutex();
midi_port_mutex = SDL_CreateMutex();
midi_play_cond = SDL_CreateCond();
if (!(midi_mutex && midi_record_mutex && midi_play_mutex && midi_port_mutex && midi_play_cond)) {
if (midi_mutex) SDL_DestroyMutex(midi_mutex);
if (midi_record_mutex) SDL_DestroyMutex(midi_record_mutex);
if (midi_play_mutex) SDL_DestroyMutex(midi_play_mutex);
if (midi_port_mutex) SDL_DestroyMutex(midi_port_mutex);
if (midi_play_cond) SDL_DestroyCond(midi_play_cond);
midi_mutex = midi_record_mutex = midi_play_mutex = midi_port_mutex = NULL;
midi_play_cond = NULL;
return 0;
}
_midi_engine_connect();
_connected = 1;
return 1;
}
示例14: pcm_init
void pcm_init()
{
int i;
SDL_AudioSpec as;
if (!sound) return;
as.freq = samplerate;
as.format = AUDIO_S16;
as.channels = 1 + stereo;
as.samples = 1024;
as.callback = audio_callback;
as.userdata = 0;
if (SDL_OpenAudio(&as, 0) == -1)
return;
pcm.hz = as.freq;
pcm.stereo = as.channels - 1;
pcm.len = as.size >> 1;
pcm.buf = malloc(pcm.len);
pcm.pos = 0;
memset(pcm.buf, 0, pcm.len);
sound_mutex = SDL_CreateMutex();
sound_cv = SDL_CreateCond();
SDL_PauseAudio(0);
}
示例15: OPL_Delay
void OPL_Delay(uint64_t us)
{
delay_data_t delay_data;
if (driver == NULL)
{
return;
}
// Create a callback that will signal this thread after the
// specified time.
delay_data.finished = 0;
delay_data.mutex = SDL_CreateMutex();
delay_data.cond = SDL_CreateCond();
OPL_SetCallback(us, DelayCallback, &delay_data);
// Wait until the callback is invoked.
SDL_LockMutex(delay_data.mutex);
while (!delay_data.finished)
{
SDL_CondWait(delay_data.cond, delay_data.mutex);
}
SDL_UnlockMutex(delay_data.mutex);
// Clean up.
SDL_DestroyMutex(delay_data.mutex);
SDL_DestroyCond(delay_data.cond);
}