Changed the name of SDL_mutexP() SDL_mutexV()
This commit is contained in:
parent
0707530b35
commit
c6388c87c1
17 changed files with 51 additions and 51 deletions
|
@ -70,8 +70,8 @@ extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void);
|
||||||
*
|
*
|
||||||
* \return 0, or -1 on error.
|
* \return 0, or -1 on error.
|
||||||
*/
|
*/
|
||||||
#define SDL_LockMutex(m) SDL_mutexP(m)
|
#define SDL_mutexP(m) SDL_LockMutex(m)
|
||||||
extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex * mutex);
|
extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to lock the mutex
|
* Try to lock the mutex
|
||||||
|
@ -88,8 +88,8 @@ extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex);
|
||||||
* \warning It is an error to unlock a mutex that has not been locked by
|
* \warning It is an error to unlock a mutex that has not been locked by
|
||||||
* the current thread, and doing so results in undefined behavior.
|
* the current thread, and doing so results in undefined behavior.
|
||||||
*/
|
*/
|
||||||
#define SDL_UnlockMutex(m) SDL_mutexV(m)
|
#define SDL_mutexV(m) SDL_UnlockMutex(m)
|
||||||
extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex * mutex);
|
extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy a mutex.
|
* Destroy a mutex.
|
||||||
|
|
|
@ -41,13 +41,13 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
|
||||||
/* Race condition on first lock... */
|
/* Race condition on first lock... */
|
||||||
_spinlock_mutex = SDL_CreateMutex();
|
_spinlock_mutex = SDL_CreateMutex();
|
||||||
}
|
}
|
||||||
SDL_mutexP(_spinlock_mutex);
|
SDL_LockMutex(_spinlock_mutex);
|
||||||
if (*lock == 0) {
|
if (*lock == 0) {
|
||||||
*lock = 1;
|
*lock = 1;
|
||||||
SDL_mutexV(_spinlock_mutex);
|
SDL_UnlockMutex(_spinlock_mutex);
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
} else {
|
} else {
|
||||||
SDL_mutexV(_spinlock_mutex);
|
SDL_UnlockMutex(_spinlock_mutex);
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ SDL_AudioLockDevice_Default(SDL_AudioDevice * device)
|
||||||
if (device->thread && (SDL_ThreadID() == device->threadid)) {
|
if (device->thread && (SDL_ThreadID() == device->threadid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SDL_mutexP(device->mixer_lock);
|
SDL_LockMutex(device->mixer_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -209,7 +209,7 @@ SDL_AudioUnlockDevice_Default(SDL_AudioDevice * device)
|
||||||
if (device->thread && (SDL_ThreadID() == device->threadid)) {
|
if (device->thread && (SDL_ThreadID() == device->threadid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SDL_mutexV(device->mixer_lock);
|
SDL_UnlockMutex(device->mixer_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -407,9 +407,9 @@ SDL_RunAudio(void *devicep)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read from the callback into the _input_ stream */
|
/* Read from the callback into the _input_ stream */
|
||||||
SDL_mutexP(device->mixer_lock);
|
SDL_LockMutex(device->mixer_lock);
|
||||||
(*fill) (udata, istream, istream_len);
|
(*fill) (udata, istream, istream_len);
|
||||||
SDL_mutexV(device->mixer_lock);
|
SDL_UnlockMutex(device->mixer_lock);
|
||||||
|
|
||||||
/* Convert the audio if necessary and write to the streamer */
|
/* Convert the audio if necessary and write to the streamer */
|
||||||
if (device->convert.needed) {
|
if (device->convert.needed) {
|
||||||
|
@ -480,9 +480,9 @@ SDL_RunAudio(void *devicep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_mutexP(device->mixer_lock);
|
SDL_LockMutex(device->mixer_lock);
|
||||||
(*fill) (udata, stream, stream_len);
|
(*fill) (udata, stream, stream_len);
|
||||||
SDL_mutexV(device->mixer_lock);
|
SDL_UnlockMutex(device->mixer_lock);
|
||||||
|
|
||||||
/* Convert the audio if necessary */
|
/* Convert the audio if necessary */
|
||||||
if (device->convert.needed) {
|
if (device->convert.needed) {
|
||||||
|
|
|
@ -54,18 +54,18 @@ FillSound(void *device, void *stream, size_t len,
|
||||||
|
|
||||||
if (!audio->paused) {
|
if (!audio->paused) {
|
||||||
if (audio->convert.needed) {
|
if (audio->convert.needed) {
|
||||||
SDL_mutexP(audio->mixer_lock);
|
SDL_LockMutex(audio->mixer_lock);
|
||||||
(*audio->spec.callback) (audio->spec.userdata,
|
(*audio->spec.callback) (audio->spec.userdata,
|
||||||
(Uint8 *) audio->convert.buf,
|
(Uint8 *) audio->convert.buf,
|
||||||
audio->convert.len);
|
audio->convert.len);
|
||||||
SDL_mutexV(audio->mixer_lock);
|
SDL_UnlockMutex(audio->mixer_lock);
|
||||||
SDL_ConvertAudio(&audio->convert);
|
SDL_ConvertAudio(&audio->convert);
|
||||||
SDL_memcpy(stream, audio->convert.buf, audio->convert.len_cvt);
|
SDL_memcpy(stream, audio->convert.buf, audio->convert.len_cvt);
|
||||||
} else {
|
} else {
|
||||||
SDL_mutexP(audio->mixer_lock);
|
SDL_LockMutex(audio->mixer_lock);
|
||||||
(*audio->spec.callback) (audio->spec.userdata,
|
(*audio->spec.callback) (audio->spec.userdata,
|
||||||
(Uint8 *) stream, len);
|
(Uint8 *) stream, len);
|
||||||
SDL_mutexV(audio->mixer_lock);
|
SDL_UnlockMutex(audio->mixer_lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,10 +280,10 @@ outputCallback(void *inRefCon,
|
||||||
while (remaining > 0) {
|
while (remaining > 0) {
|
||||||
if (this->hidden->bufferOffset >= this->hidden->bufferSize) {
|
if (this->hidden->bufferOffset >= this->hidden->bufferSize) {
|
||||||
/* Generate the data */
|
/* Generate the data */
|
||||||
SDL_mutexP(this->mixer_lock);
|
SDL_LockMutex(this->mixer_lock);
|
||||||
(*this->spec.callback)(this->spec.userdata,
|
(*this->spec.callback)(this->spec.userdata,
|
||||||
this->hidden->buffer, this->hidden->bufferSize);
|
this->hidden->buffer, this->hidden->bufferSize);
|
||||||
SDL_mutexV(this->mixer_lock);
|
SDL_UnlockMutex(this->mixer_lock);
|
||||||
this->hidden->bufferOffset = 0;
|
this->hidden->bufferOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
|
||||||
}
|
}
|
||||||
/* Lock the event queue */
|
/* Lock the event queue */
|
||||||
used = 0;
|
used = 0;
|
||||||
if (!SDL_EventQ.lock || SDL_mutexP(SDL_EventQ.lock) == 0) {
|
if (!SDL_EventQ.lock || SDL_LockMutex(SDL_EventQ.lock) == 0) {
|
||||||
if (action == SDL_ADDEVENT) {
|
if (action == SDL_ADDEVENT) {
|
||||||
for (i = 0; i < numevents; ++i) {
|
for (i = 0; i < numevents; ++i) {
|
||||||
used += SDL_AddEvent(&events[i]);
|
used += SDL_AddEvent(&events[i]);
|
||||||
|
@ -242,7 +242,7 @@ SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_mutexV(SDL_EventQ.lock);
|
SDL_UnlockMutex(SDL_EventQ.lock);
|
||||||
} else {
|
} else {
|
||||||
SDL_SetError("Couldn't lock event queue");
|
SDL_SetError("Couldn't lock event queue");
|
||||||
used = -1;
|
used = -1;
|
||||||
|
@ -285,7 +285,7 @@ SDL_FlushEvents(Uint32 minType, Uint32 maxType)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Lock the event queue */
|
/* Lock the event queue */
|
||||||
if (SDL_mutexP(SDL_EventQ.lock) == 0) {
|
if (SDL_LockMutex(SDL_EventQ.lock) == 0) {
|
||||||
int spot = SDL_EventQ.head;
|
int spot = SDL_EventQ.head;
|
||||||
while (spot != SDL_EventQ.tail) {
|
while (spot != SDL_EventQ.tail) {
|
||||||
Uint32 type = SDL_EventQ.event[spot].type;
|
Uint32 type = SDL_EventQ.event[spot].type;
|
||||||
|
@ -295,7 +295,7 @@ SDL_FlushEvents(Uint32 minType, Uint32 maxType)
|
||||||
spot = (spot + 1) % MAXEVENTS;
|
spot = (spot + 1) % MAXEVENTS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_mutexV(SDL_EventQ.lock);
|
SDL_UnlockMutex(SDL_EventQ.lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ SDL_DelEventWatch(SDL_EventFilter filter, void *userdata)
|
||||||
void
|
void
|
||||||
SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
|
SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
|
||||||
{
|
{
|
||||||
if (SDL_mutexP(SDL_EventQ.lock) == 0) {
|
if (SDL_LockMutex(SDL_EventQ.lock) == 0) {
|
||||||
int spot;
|
int spot;
|
||||||
|
|
||||||
spot = SDL_EventQ.head;
|
spot = SDL_EventQ.head;
|
||||||
|
@ -458,7 +458,7 @@ SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_mutexV(SDL_EventQ.lock);
|
SDL_UnlockMutex(SDL_EventQ.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8
|
Uint8
|
||||||
|
|
|
@ -819,7 +819,7 @@ void SDL_SYS_JoystickDetect()
|
||||||
pCurList = SYS_Joystick;
|
pCurList = SYS_Joystick;
|
||||||
SYS_Joystick = NULL;
|
SYS_Joystick = NULL;
|
||||||
s_iNewGUID = 0;
|
s_iNewGUID = 0;
|
||||||
SDL_mutexP( s_mutexJoyStickEnum );
|
SDL_LockMutex( s_mutexJoyStickEnum );
|
||||||
|
|
||||||
if ( !s_pKnownJoystickGUIDs )
|
if ( !s_pKnownJoystickGUIDs )
|
||||||
s_pKnownJoystickGUIDs = SDL_malloc( sizeof(GUID)*MAX_JOYSTICKS );
|
s_pKnownJoystickGUIDs = SDL_malloc( sizeof(GUID)*MAX_JOYSTICKS );
|
||||||
|
@ -832,7 +832,7 @@ void SDL_SYS_JoystickDetect()
|
||||||
EnumJoysticksCallback,
|
EnumJoysticksCallback,
|
||||||
&pCurList, DIEDFL_ATTACHEDONLY);
|
&pCurList, DIEDFL_ATTACHEDONLY);
|
||||||
|
|
||||||
SDL_mutexV( s_mutexJoyStickEnum );
|
SDL_UnlockMutex( s_mutexJoyStickEnum );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pCurList )
|
if ( pCurList )
|
||||||
|
|
|
@ -85,7 +85,7 @@ SDL_AddThread(SDL_Thread * thread)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_mutexP(thread_lock);
|
SDL_LockMutex(thread_lock);
|
||||||
|
|
||||||
/* Expand the list of threads, if necessary */
|
/* Expand the list of threads, if necessary */
|
||||||
#ifdef DEBUG_THREADS
|
#ifdef DEBUG_THREADS
|
||||||
|
@ -118,7 +118,7 @@ SDL_DelThread(SDL_Thread * thread)
|
||||||
if (!thread_lock) {
|
if (!thread_lock) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SDL_mutexP(thread_lock);
|
SDL_LockMutex(thread_lock);
|
||||||
for (i = 0; i < SDL_numthreads; ++i) {
|
for (i = 0; i < SDL_numthreads; ++i) {
|
||||||
if (thread == SDL_Threads[i]) {
|
if (thread == SDL_Threads[i]) {
|
||||||
break;
|
break;
|
||||||
|
@ -164,7 +164,7 @@ SDL_GetErrBuf(void)
|
||||||
SDL_threadID this_thread;
|
SDL_threadID this_thread;
|
||||||
|
|
||||||
this_thread = SDL_ThreadID();
|
this_thread = SDL_ThreadID();
|
||||||
SDL_mutexP(thread_lock);
|
SDL_LockMutex(thread_lock);
|
||||||
for (i = 0; i < SDL_numthreads; ++i) {
|
for (i = 0; i < SDL_numthreads; ++i) {
|
||||||
if (this_thread == SDL_Threads[i]->threadid) {
|
if (this_thread == SDL_Threads[i]->threadid) {
|
||||||
errbuf = &SDL_Threads[i]->errbuf;
|
errbuf = &SDL_Threads[i]->errbuf;
|
||||||
|
|
|
@ -70,7 +70,7 @@ SDL_DestroyMutex(SDL_mutex * mutex)
|
||||||
|
|
||||||
/* Lock the mutex */
|
/* Lock the mutex */
|
||||||
int
|
int
|
||||||
SDL_mutexP(SDL_mutex * mutex)
|
SDL_LockMutex(SDL_mutex * mutex)
|
||||||
{
|
{
|
||||||
#if SDL_THREADS_DISABLED
|
#if SDL_THREADS_DISABLED
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -123,8 +123,8 @@ SDL_DestroySemaphore(SDL_sem * sem)
|
||||||
}
|
}
|
||||||
SDL_DestroyCond(sem->count_nonzero);
|
SDL_DestroyCond(sem->count_nonzero);
|
||||||
if (sem->count_lock) {
|
if (sem->count_lock) {
|
||||||
SDL_mutexP(sem->count_lock);
|
SDL_LockMutex(sem->count_lock);
|
||||||
SDL_mutexV(sem->count_lock);
|
SDL_UnlockMutex(sem->count_lock);
|
||||||
SDL_DestroyMutex(sem->count_lock);
|
SDL_DestroyMutex(sem->count_lock);
|
||||||
}
|
}
|
||||||
SDL_free(sem);
|
SDL_free(sem);
|
||||||
|
|
|
@ -78,7 +78,7 @@ SDL_DestroyMutex(SDL_mutex * mutex)
|
||||||
|
|
||||||
/* Lock the mutex */
|
/* Lock the mutex */
|
||||||
int
|
int
|
||||||
SDL_mutexP(SDL_mutex * mutex)
|
SDL_LockMutex(SDL_mutex * mutex)
|
||||||
{
|
{
|
||||||
#ifdef DISABLE_THREADS
|
#ifdef DISABLE_THREADS
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -143,7 +143,7 @@ SDL_TryLockMutex(SDL_mutex * mutex)
|
||||||
|
|
||||||
/* Unlock the mutex */
|
/* Unlock the mutex */
|
||||||
int
|
int
|
||||||
SDL_mutexV(SDL_mutex * mutex)
|
SDL_UnlockMutex(SDL_mutex * mutex)
|
||||||
{
|
{
|
||||||
#ifdef DISABLE_THREADS
|
#ifdef DISABLE_THREADS
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -129,8 +129,8 @@ SDL_DestroySemaphore(SDL_sem * sem)
|
||||||
SDL_Delay(10);
|
SDL_Delay(10);
|
||||||
}
|
}
|
||||||
SDL_DestroyCond(sem->count_nonzero);
|
SDL_DestroyCond(sem->count_nonzero);
|
||||||
SDL_mutexP(sem->count_lock);
|
SDL_LockMutex(sem->count_lock);
|
||||||
SDL_mutexV(sem->count_lock);
|
SDL_UnlockMutex(sem->count_lock);
|
||||||
SDL_DestroyMutex(sem->count_lock);
|
SDL_DestroyMutex(sem->count_lock);
|
||||||
free(sem);
|
free(sem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ SDL_DestroyMutex(SDL_mutex * mutex)
|
||||||
|
|
||||||
/* Lock the mutex */
|
/* Lock the mutex */
|
||||||
int
|
int
|
||||||
SDL_mutexP(SDL_mutex * mutex)
|
SDL_LockMutex(SDL_mutex * mutex)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
#if FAKE_RECURSIVE_MUTEX
|
#if FAKE_RECURSIVE_MUTEX
|
||||||
|
@ -165,7 +165,7 @@ SDL_TryLockMutex(SDL_mutex * mutex)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SDL_mutexV(SDL_mutex * mutex)
|
SDL_UnlockMutex(SDL_mutex * mutex)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ SDL_DestroyMutex(SDL_mutex * mutex)
|
||||||
|
|
||||||
/* Lock the mutex */
|
/* Lock the mutex */
|
||||||
int
|
int
|
||||||
SDL_mutexP(SDL_mutex * mutex)
|
SDL_LockMutex(SDL_mutex * mutex)
|
||||||
{
|
{
|
||||||
if (mutex == NULL) {
|
if (mutex == NULL) {
|
||||||
SDL_SetError("Passed a NULL mutex");
|
SDL_SetError("Passed a NULL mutex");
|
||||||
|
@ -93,7 +93,7 @@ SDL_TryLockMutex(SDL_mutex * mutex)
|
||||||
|
|
||||||
/* Unlock the mutex */
|
/* Unlock the mutex */
|
||||||
int
|
int
|
||||||
SDL_mutexV(SDL_mutex * mutex)
|
SDL_UnlockMutex(SDL_mutex * mutex)
|
||||||
{
|
{
|
||||||
if (mutex == NULL) {
|
if (mutex == NULL) {
|
||||||
SDL_SetError("Passed a NULL mutex");
|
SDL_SetError("Passed a NULL mutex");
|
||||||
|
|
|
@ -334,10 +334,10 @@ SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param)
|
||||||
entry->timer = timer;
|
entry->timer = timer;
|
||||||
entry->timerID = timer->timerID;
|
entry->timerID = timer->timerID;
|
||||||
|
|
||||||
SDL_mutexP(data->timermap_lock);
|
SDL_LockMutex(data->timermap_lock);
|
||||||
entry->next = data->timermap;
|
entry->next = data->timermap;
|
||||||
data->timermap = entry;
|
data->timermap = entry;
|
||||||
SDL_mutexV(data->timermap_lock);
|
SDL_UnlockMutex(data->timermap_lock);
|
||||||
|
|
||||||
/* Add the timer to the pending list for the timer thread */
|
/* Add the timer to the pending list for the timer thread */
|
||||||
SDL_AtomicLock(&data->lock);
|
SDL_AtomicLock(&data->lock);
|
||||||
|
@ -359,7 +359,7 @@ SDL_RemoveTimer(SDL_TimerID id)
|
||||||
SDL_bool canceled = SDL_FALSE;
|
SDL_bool canceled = SDL_FALSE;
|
||||||
|
|
||||||
/* Find the timer */
|
/* Find the timer */
|
||||||
SDL_mutexP(data->timermap_lock);
|
SDL_LockMutex(data->timermap_lock);
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
for (entry = data->timermap; entry; prev = entry, entry = entry->next) {
|
for (entry = data->timermap; entry; prev = entry, entry = entry->next) {
|
||||||
if (entry->timerID == id) {
|
if (entry->timerID == id) {
|
||||||
|
@ -371,7 +371,7 @@ SDL_RemoveTimer(SDL_TimerID id)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_mutexV(data->timermap_lock);
|
SDL_UnlockMutex(data->timermap_lock);
|
||||||
|
|
||||||
if (entry) {
|
if (entry) {
|
||||||
if (!entry->timer->canceled) {
|
if (!entry->timer->canceled) {
|
||||||
|
|
|
@ -412,7 +412,7 @@ static SDL_bool EnqueueEvent_Mutex(SDL_EventQueue *queue, const SDL_Event *event
|
||||||
int delta;
|
int delta;
|
||||||
SDL_bool status = SDL_FALSE;
|
SDL_bool status = SDL_FALSE;
|
||||||
|
|
||||||
SDL_mutexP(queue->mutex);
|
SDL_LockMutex(queue->mutex);
|
||||||
|
|
||||||
queue_pos = (unsigned)queue->enqueue_pos.value;
|
queue_pos = (unsigned)queue->enqueue_pos.value;
|
||||||
entry = &queue->entries[queue_pos & WRAP_MASK];
|
entry = &queue->entries[queue_pos & WRAP_MASK];
|
||||||
|
@ -432,7 +432,7 @@ static SDL_bool EnqueueEvent_Mutex(SDL_EventQueue *queue, const SDL_Event *event
|
||||||
printf("ERROR: mutex failed!\n");
|
printf("ERROR: mutex failed!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_mutexV(queue->mutex);
|
SDL_UnlockMutex(queue->mutex);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -445,7 +445,7 @@ static SDL_bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event)
|
||||||
int delta;
|
int delta;
|
||||||
SDL_bool status = SDL_FALSE;
|
SDL_bool status = SDL_FALSE;
|
||||||
|
|
||||||
SDL_mutexP(queue->mutex);
|
SDL_LockMutex(queue->mutex);
|
||||||
|
|
||||||
queue_pos = (unsigned)queue->dequeue_pos.value;
|
queue_pos = (unsigned)queue->dequeue_pos.value;
|
||||||
entry = &queue->entries[queue_pos & WRAP_MASK];
|
entry = &queue->entries[queue_pos & WRAP_MASK];
|
||||||
|
@ -465,7 +465,7 @@ static SDL_bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event)
|
||||||
printf("ERROR: mutex failed!\n");
|
printf("ERROR: mutex failed!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_mutexV(queue->mutex);
|
SDL_UnlockMutex(queue->mutex);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,14 +69,14 @@ Run(void *data)
|
||||||
signal(SIGTERM, closemutex);
|
signal(SIGTERM, closemutex);
|
||||||
while (!doterminate) {
|
while (!doterminate) {
|
||||||
printf("Process %lu ready to work\n", SDL_ThreadID());
|
printf("Process %lu ready to work\n", SDL_ThreadID());
|
||||||
if (SDL_mutexP(mutex) < 0) {
|
if (SDL_LockMutex(mutex) < 0) {
|
||||||
fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError());
|
fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
printf("Process %lu, working!\n", SDL_ThreadID());
|
printf("Process %lu, working!\n", SDL_ThreadID());
|
||||||
SDL_Delay(1 * 1000);
|
SDL_Delay(1 * 1000);
|
||||||
printf("Process %lu, done!\n", SDL_ThreadID());
|
printf("Process %lu, done!\n", SDL_ThreadID());
|
||||||
if (SDL_mutexV(mutex) < 0) {
|
if (SDL_UnlockMutex(mutex) < 0) {
|
||||||
fprintf(stderr, "Couldn't unlock mutex: %s", SDL_GetError());
|
fprintf(stderr, "Couldn't unlock mutex: %s", SDL_GetError());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue