Rename MT functions, add tests, fix bugs

Renamed multithreaded related functions, added simple unit tests and fix
bugs caught by said tests :)
This commit is contained in:
2025-06-24 16:38:43 +03:00
parent 9212dbc7c2
commit 703fb0f240
15 changed files with 175 additions and 46 deletions

View File

@@ -98,9 +98,9 @@ If the mutex is locked by another thread, the behavior is undefined.
Returns 0 on success, otherwise an error code.
=head2 BH_MutexLockTry
=head2 BH_MutexTryLock
int BH_MutexLockTry(BH_Mutex *mutex);
int BH_MutexTryLock(BH_Mutex *mutex);
Attempts to lock the mutex.
@@ -144,9 +144,9 @@ the semaphore value becomes greater than 0.
Returns 0 on success, otherwise an error code.
=head2 BH_SemaphoreWaitTry
=head2 BH_SemaphoreTryWait
int BH_SemaphoreWaitTry(BH_Semaphore *semaphore);
int BH_SemaphoreTryWait(BH_Semaphore *semaphore);
Attempts to decrease the semaphore value by 1.
@@ -244,9 +244,9 @@ Returns 0 on success, otherwise an error code.
Locks the spinlock.
=head2 BH_SpinlockLockTry
=head2 BH_SpinlockTryLock
int BH_SpinlockLockTry(int *lock);
int BH_SpinlockTryLock(int *lock);
Attempts to lock the spinlock.

View File

@@ -97,9 +97,9 @@ I<callback> и данными I<data>.
В случае успеха возвращает 0, иначе код ошибки.
=head2 BH_MutexLockTry
=head2 BH_MutexTryLock
int BH_MutexLockTry(BH_Mutex *mutex);
int BH_MutexTryLock(BH_Mutex *mutex);
Производит попытку захвата мьютекса.
@@ -143,9 +143,9 @@ I<callback> и данными I<data>.
В случае успеха возвращает 0, иначе код ошибки.
=head2 BH_SemaphoreWaitTry
=head2 BH_SemaphoreTryWait
int BH_SemaphoreWaitTry(BH_Semaphore *semaphore);
int BH_SemaphoreTryWait(BH_Semaphore *semaphore);
Пытается уменьшить значение семафора на 1.
@@ -244,9 +244,9 @@ I<timeout>.
Блокирует спинлок.
=head2 BH_SpinlockLockTry
=head2 BH_SpinlockTryLock
int BH_SpinlockLockTry(int *lock);
int BH_SpinlockTryLock(int *lock);
Пытается заблокировать спинлок.