mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-27 19:19:41 +08:00
@@ -707,6 +707,8 @@ The following functions have been renamed:
|
|||||||
|
|
||||||
## SDL_mutex.h
|
## SDL_mutex.h
|
||||||
|
|
||||||
|
SDL_MUTEX_MAXWAIT has been removed; it suggested there was a maximum timeout one could outlive, instead of an infinite wait. Instead, pass a -1 to functions that accepted this symbol.
|
||||||
|
|
||||||
SDL_LockMutex and SDL_UnlockMutex now return void; if the mutex is valid (including being a NULL pointer, which returns immediately), these functions never fail. If the mutex is invalid or the caller does something illegal, like unlock another thread's mutex, this is considered undefined behavior.
|
SDL_LockMutex and SDL_UnlockMutex now return void; if the mutex is valid (including being a NULL pointer, which returns immediately), these functions never fail. If the mutex is invalid or the caller does something illegal, like unlock another thread's mutex, this is considered undefined behavior.
|
||||||
|
|
||||||
The following functions have been renamed:
|
The following functions have been renamed:
|
||||||
|
|||||||
@@ -121,11 +121,6 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
#define SDL_MUTEX_TIMEDOUT 1
|
#define SDL_MUTEX_TIMEDOUT 1
|
||||||
|
|
||||||
/**
|
|
||||||
* This is the timeout value which corresponds to never time out.
|
|
||||||
*/
|
|
||||||
#define SDL_MUTEX_MAXWAIT -1
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \name Mutex functions
|
* \name Mutex functions
|
||||||
@@ -535,7 +530,7 @@ extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_Semaphore *sem);
|
|||||||
* semaphore value.
|
* semaphore value.
|
||||||
*
|
*
|
||||||
* This function is the equivalent of calling SDL_WaitSemaphoreTimeout() with
|
* This function is the equivalent of calling SDL_WaitSemaphoreTimeout() with
|
||||||
* a time length of `SDL_MUTEX_MAXWAIT`.
|
* a time length of -1.
|
||||||
*
|
*
|
||||||
* \param sem the semaphore wait on
|
* \param sem the semaphore wait on
|
||||||
* \returns 0 on success or a negative error code on failure; call
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
@@ -722,7 +717,7 @@ extern DECLSPEC int SDLCALL SDL_BroadcastCondition(SDL_Condition *cond);
|
|||||||
* behavior.
|
* behavior.
|
||||||
*
|
*
|
||||||
* This function is the equivalent of calling SDL_WaitConditionTimeout() with
|
* This function is the equivalent of calling SDL_WaitConditionTimeout() with
|
||||||
* a time length of `SDL_MUTEX_MAXWAIT`.
|
* a time length of -1.
|
||||||
*
|
*
|
||||||
* \param cond the condition variable to wait on
|
* \param cond the condition variable to wait on
|
||||||
* \param mutex the mutex used to coordinate thread access
|
* \param mutex the mutex used to coordinate thread access
|
||||||
@@ -755,7 +750,7 @@ extern DECLSPEC int SDLCALL SDL_WaitCondition(SDL_Condition *cond, SDL_Mutex *mu
|
|||||||
* \param cond the condition variable to wait on
|
* \param cond the condition variable to wait on
|
||||||
* \param mutex the mutex used to coordinate thread access
|
* \param mutex the mutex used to coordinate thread access
|
||||||
* \param timeoutMS the maximum time to wait, in milliseconds, or
|
* \param timeoutMS the maximum time to wait, in milliseconds, or
|
||||||
* `SDL_MUTEX_MAXWAIT` to wait indefinitely
|
* -1 to wait indefinitely
|
||||||
* \returns 0 if the condition variable is signaled, `SDL_MUTEX_TIMEDOUT` if
|
* \returns 0 if the condition variable is signaled, `SDL_MUTEX_TIMEDOUT` if
|
||||||
* the condition is not signaled in the allotted time, or a negative
|
* the condition is not signaled in the allotted time, or a negative
|
||||||
* error code on failure; call SDL_GetError() for more information.
|
* error code on failure; call SDL_GetError() for more information.
|
||||||
|
|||||||
@@ -472,7 +472,7 @@ void SDL_DetachThread(SDL_Thread *thread)
|
|||||||
|
|
||||||
int SDL_WaitSemaphore(SDL_Semaphore *sem)
|
int SDL_WaitSemaphore(SDL_Semaphore *sem)
|
||||||
{
|
{
|
||||||
return SDL_WaitSemaphoreTimeoutNS(sem, SDL_MUTEX_MAXWAIT);
|
return SDL_WaitSemaphoreTimeoutNS(sem, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_TryWaitSemaphore(SDL_Semaphore *sem)
|
int SDL_TryWaitSemaphore(SDL_Semaphore *sem)
|
||||||
@@ -494,7 +494,7 @@ int SDL_WaitSemaphoreTimeout(SDL_Semaphore *sem, Sint32 timeoutMS)
|
|||||||
|
|
||||||
int SDL_WaitCondition(SDL_Condition *cond, SDL_Mutex *mutex)
|
int SDL_WaitCondition(SDL_Condition *cond, SDL_Mutex *mutex)
|
||||||
{
|
{
|
||||||
return SDL_WaitConditionTimeoutNS(cond, mutex, SDL_MUTEX_MAXWAIT);
|
return SDL_WaitConditionTimeoutNS(cond, mutex, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_WaitConditionTimeout(SDL_Condition *cond, SDL_Mutex *mutex, Sint32 timeoutMS)
|
int SDL_WaitConditionTimeout(SDL_Condition *cond, SDL_Mutex *mutex, Sint32 timeoutMS)
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
|
|||||||
return SDL_InvalidParamError("sem");
|
return SDL_InvalidParamError("sem");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeoutNS == SDL_MUTEX_MAXWAIT) {
|
if (timeoutNS == -1) { // -1 == wait indefinitely.
|
||||||
LightSemaphore_Acquire(&sem->semaphore, 1);
|
LightSemaphore_Acquire(&sem->semaphore, 1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
|
|||||||
return SDL_MUTEX_TIMEOUT;
|
return SDL_MUTEX_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeoutNS == SDL_MUTEX_MAXWAIT) {
|
if (timeoutNS == -1) { // -1 == wait indefinitely.
|
||||||
WaitAll(sem);
|
WaitAll(sem);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeoutNS != SDL_MUTEX_MAXWAIT) {
|
if (timeoutNS != -1) { // -1 == wait indefinitely.
|
||||||
SetTimerAlarm(&alarm, MSec2TimerBusClock(SDL_NS_TO_MS(timeoutNS)), &usercb, (void *)GetThreadId());
|
SetTimerAlarm(&alarm, MSec2TimerBusClock(SDL_NS_TO_MS(timeoutNS)), &usercb, (void *)GetThreadId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ void SDL_DestroySemaphore(SDL_Semaphore *sem)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: This routine is a bit overloaded.
|
/* TODO: This routine is a bit overloaded.
|
||||||
* If the timeout is 0 then just poll the semaphore; if it's SDL_MUTEX_MAXWAIT, pass
|
* If the timeout is 0 then just poll the semaphore; if it's -1, pass
|
||||||
* NULL to sceKernelWaitSema() so that it waits indefinitely; and if the timeout
|
* NULL to sceKernelWaitSema() so that it waits indefinitely; and if the timeout
|
||||||
* is specified, convert it to microseconds. */
|
* is specified, convert it to microseconds. */
|
||||||
int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
|
int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ void SDL_DestroySemaphore(SDL_Semaphore *sem)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: This routine is a bit overloaded.
|
/* TODO: This routine is a bit overloaded.
|
||||||
* If the timeout is 0 then just poll the semaphore; if it's SDL_MUTEX_MAXWAIT, pass
|
* If the timeout is 0 then just poll the semaphore; if it's -1, pass
|
||||||
* NULL to sceKernelWaitSema() so that it waits indefinitely; and if the timeout
|
* NULL to sceKernelWaitSema() so that it waits indefinitely; and if the timeout
|
||||||
* is specified, convert it to microseconds. */
|
* is specified, convert it to microseconds. */
|
||||||
int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
|
int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ static int SDLCALL SDL_TimerThread(void *_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initial delay if there are no timers */
|
/* Initial delay if there are no timers */
|
||||||
delay = (Uint64)SDL_MUTEX_MAXWAIT;
|
delay = (Uint64)-1;
|
||||||
|
|
||||||
tick = SDL_GetTicksNS();
|
tick = SDL_GetTicksNS();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user