Skip to content

Commit 725dca3

Browse files
Update SDL_mutex.inc to 3.4.4
1 parent 7ed6076 commit 725dca3

2 files changed

Lines changed: 93 additions & 1 deletion

File tree

units/SDL3.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ interface
127127
{$I SDL_process.inc} // 3.4.4
128128
{$I SDL_storage.inc} // 3.4.4
129129
{$I SDL_tray.inc} // 3.4.4
130-
{$I SDL_mutex.inc} // 3.2.12
130+
{$I SDL_mutex.inc} // 3.4.4
131131

132132

133133

units/SDL_mutex.inc

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ function SDL_CreateMutex(): PSDL_Mutex; cdecl;
5454
*
5555
* \param mutex the mutex to lock.
5656
*
57+
* \threadsafety It is safe to call this function from any thread.
58+
*
5759
* \since This function is available since SDL 3.2.0.
5860
*
5961
* \sa SDL_TryLockMutex
@@ -76,6 +78,8 @@ procedure SDL_LockMutex(mutex: PSDL_Mutex); cdecl;
7678
* \param mutex the mutex to try to lock.
7779
* \returns true on success, false if the mutex would block.
7880
*
81+
* \threadsafety It is safe to call this function from any thread.
82+
*
7983
* \since This function is available since SDL 3.2.0.
8084
*
8185
* \sa SDL_LockMutex
@@ -96,6 +100,9 @@ function SDL_TryLockMutex(mutex: PSDL_Mutex): Boolean; cdecl;
96100
*
97101
* \param mutex the mutex to unlock.
98102
*
103+
* \threadsafety This call must be paired with a previous locking call on the
104+
* same thread.
105+
*
99106
* \since This function is available since SDL 3.2.0.
100107
*
101108
* \sa SDL_LockMutex
@@ -115,6 +122,8 @@ procedure SDL_UnlockMutex(mutex: PSDL_Mutex); cdecl;
115122
*
116123
* \param mutex the mutex to destroy.
117124
*
125+
* \threadsafety It is safe to call this function from any thread.
126+
*
118127
* \since This function is available since SDL 3.2.0.
119128
*
120129
* \sa SDL_CreateMutex
@@ -175,6 +184,8 @@ type
175184
* \returns the initialized and unlocked read/write lock or NULL on failure;
176185
* call SDL_GetError() for more information.
177186
*
187+
* \threadsafety It is safe to call this function from any thread.
188+
*
178189
* \since This function is available since SDL 3.2.0.
179190
*
180191
* \sa SDL_DestroyRWLock
@@ -216,6 +227,8 @@ function SDL_CreateRWLock(): PSDL_RWLock; cdecl;
216227
*
217228
* \param rwlock the read/write lock to lock.
218229
*
230+
* \threadsafety It is safe to call this function from any thread.
231+
*
219232
* \since This function is available since SDL 3.2.0.
220233
*
221234
* \sa SDL_LockRWLockForWriting
@@ -248,6 +261,8 @@ procedure SDL_LockRWLockForReading(rwlock: PSDL_RWLock); cdecl;
248261
*
249262
* \param rwlock the read/write lock to lock.
250263
*
264+
* \threadsafety It is safe to call this function from any thread.
265+
*
251266
* \since This function is available since SDL 3.2.0.
252267
*
253268
* \sa SDL_LockRWLockForReading
@@ -274,6 +289,8 @@ procedure SDL_LockRWLockForWriting(rwlock: PSDL_RWLock); cdecl;
274289
* \param rwlock the rwlock to try to lock.
275290
* \returns true on success, false if the lock would block.
276291
*
292+
* \threadsafety It is safe to call this function from any thread.
293+
*
277294
* \since This function is available since SDL 3.2.0.
278295
*
279296
* \sa SDL_LockRWLockForReading
@@ -305,6 +322,8 @@ function SDL_TryLockRWLockForReading(rwlock: PSDL_RWLock): Boolean; cdecl;
305322
* \param rwlock the rwlock to try to lock.
306323
* \returns true on success, false if the lock would block.
307324
*
325+
* \threadsafety It is safe to call this function from any thread.
326+
*
308327
* \since This function is available since SDL 3.2.0.
309328
*
310329
* \sa SDL_LockRWLockForWriting
@@ -330,6 +349,9 @@ function SDL_TryLockRWLockForWriting(rwlock: PSDL_RWLock): Boolean; cdecl;
330349
*
331350
* \param rwlock the rwlock to unlock.
332351
*
352+
* \threadsafety This call must be paired with a previous locking call on the
353+
* same thread.
354+
*
333355
* \since This function is available since SDL 3.2.0.
334356
*
335357
* \sa SDL_LockRWLockForReading
@@ -351,6 +373,8 @@ procedure SDL_UnlockRWLock(rwlock: PSDL_RWLock); cdecl;
351373
*
352374
* \param rwlock the rwlock to destroy.
353375
*
376+
* \threadsafety It is safe to call this function from any thread.
377+
*
354378
* \since This function is available since SDL 3.2.0.
355379
*
356380
* \sa SDL_CreateRWLock
@@ -389,6 +413,8 @@ type
389413
* \returns a new semaphore or NULL on failure; call SDL_GetError() for more
390414
* information.
391415
*
416+
* \threadsafety It is safe to call this function from any thread.
417+
*
392418
* \since This function is available since SDL 3.2.0.
393419
*
394420
* \sa SDL_DestroySemaphore
@@ -409,6 +435,8 @@ function SDL_CreateSemaphore(initial_value: cuint32): PSDL_Semaphore; cdecl;
409435
*
410436
* \param sem the semaphore to destroy.
411437
*
438+
* \threadsafety It is safe to call this function from any thread.
439+
*
412440
* \since This function is available since SDL 3.2.0.
413441
*
414442
* \sa SDL_CreateSemaphore
@@ -428,6 +456,8 @@ procedure SDL_DestroySemaphore(sem: PSDL_Semaphore); cdecl;
428456
*
429457
* \param sem the semaphore wait on.
430458
*
459+
* \threadsafety It is safe to call this function from any thread.
460+
*
431461
* \since This function is available since SDL 3.2.0.
432462
*
433463
* \sa SDL_SignalSemaphore
@@ -448,6 +478,8 @@ procedure SDL_WaitSemaphore(sem: PSDL_Semaphore); cdecl;
448478
* \param sem the semaphore to wait on.
449479
* \returns true if the wait succeeds, false if the wait would block.
450480
*
481+
* \threadsafety It is safe to call this function from any thread.
482+
*
451483
* \since This function is available since SDL 3.2.0.
452484
*
453485
* \sa SDL_SignalSemaphore
@@ -469,6 +501,8 @@ function SDL_TryWaitSemaphore(sem: PSDL_Semaphore): Boolean; cdecl;
469501
* indefinitely.
470502
* \returns true if the wait succeeds or false if the wait times out.
471503
*
504+
* \threadsafety It is safe to call this function from any thread.
505+
*
472506
* \since This function is available since SDL 3.2.0.
473507
*
474508
* \sa SDL_SignalSemaphore
@@ -483,6 +517,8 @@ function SDL_WaitSemaphoreTimeout(sem: PSDL_Semaphore; timeoutMS: cint32): Boole
483517
*
484518
* \param sem the semaphore to increment.
485519
*
520+
* \threadsafety It is safe to call this function from any thread.
521+
*
486522
* \since This function is available since SDL 3.2.0.
487523
*
488524
* \sa SDL_TryWaitSemaphore
@@ -498,11 +534,17 @@ procedure SDL_SignalSemaphore(sem: PSDL_Semaphore); cdecl;
498534
* \param sem the semaphore to query.
499535
* \returns the current value of the semaphore.
500536
*
537+
* \threadsafety It is safe to call this function from any thread.
538+
*
501539
* \since This function is available since SDL 3.2.0.
502540
*}
503541
function SDL_GetSemaphoreValue(sem: PSDL_Semaphore): cuint32; cdecl;
504542
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetSemaphoreValue' {$ENDIF} {$ENDIF};
505543

544+
{
545+
* \name Condition variable functions
546+
}
547+
506548
{**
507549
* A means to block multiple threads until a condition is satisfied.
508550
*
@@ -526,6 +568,8 @@ type
526568
* \returns a new condition variable or NULL on failure; call SDL_GetError()
527569
* for more information.
528570
*
571+
* \threadsafety It is safe to call this function from any thread.
572+
*
529573
* \since This function is available since SDL 3.2.0.
530574
*
531575
* \sa SDL_BroadcastCondition
@@ -542,6 +586,8 @@ function SDL_CreateCondition(): PSDL_Condition; cdecl;
542586
*
543587
* \param cond the condition variable to destroy.
544588
*
589+
* \threadsafety It is safe to call this function from any thread.
590+
*
545591
* \since This function is available since SDL 3.2.0.
546592
*
547593
* \sa SDL_CreateCondition
@@ -664,6 +710,52 @@ Const
664710
{**
665711
* A structure used for thread-safe initialization and shutdown.
666712
*
713+
* Here is an example of using this:
714+
*
715+
* ```c
716+
* static SDL_InitState init;
717+
*
718+
* bool InitSystem(void)
719+
* (
720+
* if (!SDL_ShouldInit(&init)) (
721+
* // The system is initialized
722+
* return true;
723+
* )
724+
*
725+
* // At this point, you should not leave this function without calling SDL_SetInitialized()
726+
*
727+
* bool initialized = DoInitTasks();
728+
* SDL_SetInitialized(&init, initialized);
729+
* return initialized;
730+
* )
731+
*
732+
* bool UseSubsystem(void)
733+
* (
734+
* if (SDL_ShouldInit(&init)) (
735+
* // Error, the subsystem isn't initialized
736+
* SDL_SetInitialized(&init, false);
737+
* return false;
738+
* )
739+
*
740+
* // Do work using the initialized subsystem
741+
*
742+
* return true;
743+
* )
744+
*
745+
* void QuitSystem(void)
746+
* (
747+
* if (!SDL_ShouldQuit(&init)) (
748+
* // The system is not initialized
749+
* return;
750+
* )
751+
*
752+
* // At this point, you should not leave this function without calling SDL_SetInitialized()
753+
*
754+
* DoQuitTasks();
755+
* SDL_SetInitialized(&init, false);
756+
* )
757+
* ```
758+
*
667759
* Note that this doesn't protect any resources created during initialization,
668760
* or guarantee that nobody is using those resources during cleanup. You
669761
* should use other mechanisms to protect those, if that's a concern for your

0 commit comments

Comments
 (0)