mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 01:26:50 -04:00
Allow naming mutexes/waitables
This commit is contained in:
parent
f8b388551d
commit
ba68f4c625
@ -522,7 +522,7 @@ static void Music_Init(void) {
|
|||||||
/* music is delayed between 2 - 7 minutes by default */
|
/* music is delayed between 2 - 7 minutes by default */
|
||||||
music_minDelay = Options_GetInt(OPT_MIN_MUSIC_DELAY, 0, 3600, 120) * MILLIS_PER_SEC;
|
music_minDelay = Options_GetInt(OPT_MIN_MUSIC_DELAY, 0, 3600, 120) * MILLIS_PER_SEC;
|
||||||
music_maxDelay = Options_GetInt(OPT_MAX_MUSIC_DELAY, 0, 3600, 420) * MILLIS_PER_SEC;
|
music_maxDelay = Options_GetInt(OPT_MAX_MUSIC_DELAY, 0, 3600, 420) * MILLIS_PER_SEC;
|
||||||
music_waitable = Waitable_Create();
|
music_waitable = Waitable_Create("Music sleep");
|
||||||
|
|
||||||
volume = Options_GetInt(OPT_MUSIC_VOLUME, 0, 100, DEFAULT_MUSIC_VOLUME);
|
volume = Options_GetInt(OPT_MUSIC_VOLUME, 0, 100, DEFAULT_MUSIC_VOLUME);
|
||||||
Audio_SetMusic(volume);
|
Audio_SetMusic(volume);
|
||||||
|
@ -941,7 +941,7 @@ cc_bool AudioBackend_Init(void) {
|
|||||||
if (switchAudio) return true;
|
if (switchAudio) return true;
|
||||||
switchAudio = true;
|
switchAudio = true;
|
||||||
|
|
||||||
if (!audrv_mutex) audrv_mutex = Mutex_Create();
|
if (!audrv_mutex) audrv_mutex = Mutex_Create("Audio sync");
|
||||||
|
|
||||||
Mem_Set(audioPools, 0, sizeof(audioPools));
|
Mem_Set(audioPools, 0, sizeof(audioPools));
|
||||||
|
|
||||||
|
@ -1377,10 +1377,10 @@ static void Http_Init(void) {
|
|||||||
RequestList_Init(&pendingReqs);
|
RequestList_Init(&pendingReqs);
|
||||||
RequestList_Init(&processedReqs);
|
RequestList_Init(&processedReqs);
|
||||||
|
|
||||||
workerWaitable = Waitable_Create();
|
workerWaitable = Waitable_Create("HTTP wakeup");
|
||||||
pendingMutex = Mutex_Create();
|
pendingMutex = Mutex_Create("HTTP pending");
|
||||||
processedMutex = Mutex_Create();
|
processedMutex = Mutex_Create("HTTP processed");
|
||||||
curRequestMutex = Mutex_Create();
|
curRequestMutex = Mutex_Create("HTTP current");
|
||||||
|
|
||||||
Thread_Run(&workerThread, WorkerLoop, 128 * 1024, "HTTP");
|
Thread_Run(&workerThread, WorkerLoop, 128 * 1024, "HTTP");
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ CC_API void Thread_Detach(void* handle);
|
|||||||
CC_API void Thread_Join(void* handle);
|
CC_API void Thread_Join(void* handle);
|
||||||
|
|
||||||
/* Allocates a new mutex. (used to synchronise access to a shared resource) */
|
/* Allocates a new mutex. (used to synchronise access to a shared resource) */
|
||||||
CC_API void* Mutex_Create(void);
|
CC_API void* Mutex_Create(const char* name);
|
||||||
/* Frees an allocated mutex. */
|
/* Frees an allocated mutex. */
|
||||||
CC_API void Mutex_Free(void* handle);
|
CC_API void Mutex_Free(void* handle);
|
||||||
/* Locks the given mutex, blocking other threads from entering. */
|
/* Locks the given mutex, blocking other threads from entering. */
|
||||||
@ -235,7 +235,7 @@ CC_API void Mutex_Lock(void* handle);
|
|||||||
CC_API void Mutex_Unlock(void* handle);
|
CC_API void Mutex_Unlock(void* handle);
|
||||||
|
|
||||||
/* Allocates a new waitable. (used to conditionally wake-up a blocked thread) */
|
/* Allocates a new waitable. (used to conditionally wake-up a blocked thread) */
|
||||||
CC_API void* Waitable_Create(void);
|
CC_API void* Waitable_Create(const char* name);
|
||||||
/* Frees an allocated waitable. */
|
/* Frees an allocated waitable. */
|
||||||
CC_API void Waitable_Free(void* handle);
|
CC_API void Waitable_Free(void* handle);
|
||||||
/* Signals a waitable, waking up blocked threads. */
|
/* Signals a waitable, waking up blocked threads. */
|
||||||
|
@ -228,7 +228,7 @@ void Thread_Join(void* handle) {
|
|||||||
threadFree(thread);
|
threadFree(thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
LightLock* lock = (LightLock*)Mem_Alloc(1, sizeof(LightLock), "mutex");
|
LightLock* lock = (LightLock*)Mem_Alloc(1, sizeof(LightLock), "mutex");
|
||||||
LightLock_Init(lock);
|
LightLock_Init(lock);
|
||||||
return lock;
|
return lock;
|
||||||
@ -246,7 +246,7 @@ void Mutex_Unlock(void* handle) {
|
|||||||
LightLock_Unlock((LightLock*)handle);
|
LightLock_Unlock((LightLock*)handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
LightEvent* event = (LightEvent*)Mem_Alloc(1, sizeof(LightEvent), "waitable");
|
LightEvent* event = (LightEvent*)Mem_Alloc(1, sizeof(LightEvent), "waitable");
|
||||||
LightEvent_Init(event, RESET_ONESHOT);
|
LightEvent_Init(event, RESET_ONESHOT);
|
||||||
return event;
|
return event;
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#if defined CC_BUILD_BEOS || defined CC_BUILD_HAIKU
|
#if defined CC_BUILD_BEOS || defined CC_BUILD_HAIKU
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
#include "Platform.h"
|
||||||
#include "String.h"
|
#include "String.h"
|
||||||
#include "Funcs.h"
|
#include "Funcs.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
}
|
}
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <Application.h>
|
#include <OS.h>
|
||||||
|
#include <Roster.h>
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*--------------------------------------------------------Platform---------------------------------------------------------*
|
*--------------------------------------------------------Platform---------------------------------------------------------*
|
||||||
@ -38,7 +40,6 @@ cc_result Process_StartOpen(const cc_string* args) {
|
|||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
// NOTE: BeOS only, as haiku uses the more efficient pthreads implementation in Platform_Posix.c
|
// NOTE: BeOS only, as haiku uses the more efficient pthreads implementation in Platform_Posix.c
|
||||||
#if defined CC_BUILD_BEOS
|
#if defined CC_BUILD_BEOS
|
||||||
#include <OS.h>
|
|
||||||
void Thread_Sleep(cc_uint32 milliseconds) { snooze(milliseconds * 1000); }
|
void Thread_Sleep(cc_uint32 milliseconds) { snooze(milliseconds * 1000); }
|
||||||
|
|
||||||
static int32 ExecThread(void* param) {
|
static int32 ExecThread(void* param) {
|
||||||
@ -60,8 +61,8 @@ void Thread_Join(void* handle) {
|
|||||||
wait_for_thread(thread, NULL);
|
wait_for_thread(thread, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
sem_id id = create_sem(1, "CC MUTEX");
|
sem_id id = create_sem(1, name);
|
||||||
return (void*)id;
|
return (void*)id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,8 +81,8 @@ void Mutex_Unlock(void* handle) {
|
|||||||
release_sem(id);
|
release_sem(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
sem_id id = create_sem(0, "CC WAITABLE");
|
sem_id id = create_sem(0, name);
|
||||||
return (void*)id;
|
return (void*)id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,3 +107,4 @@ void Waitable_WaitFor(void* handle, cc_uint32 milliseconds) {
|
|||||||
acquire_sem_etc(id, 1, B_RELATIVE_TIMEOUT, microseconds);
|
acquire_sem_etc(id, 1, B_RELATIVE_TIMEOUT, microseconds);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
@ -272,7 +272,7 @@ void Thread_Join(void* handle) {
|
|||||||
thd_join((kthread_t*)handle, NULL);
|
thd_join((kthread_t*)handle, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
mutex_t* ptr = (mutex_t*)Mem_Alloc(1, sizeof(mutex_t), "mutex");
|
mutex_t* ptr = (mutex_t*)Mem_Alloc(1, sizeof(mutex_t), "mutex");
|
||||||
int res = mutex_init(ptr, MUTEX_TYPE_NORMAL);
|
int res = mutex_init(ptr, MUTEX_TYPE_NORMAL);
|
||||||
if (res) Logger_Abort2(errno, "Creating mutex");
|
if (res) Logger_Abort2(errno, "Creating mutex");
|
||||||
@ -295,7 +295,7 @@ void Mutex_Unlock(void* handle) {
|
|||||||
if (res) Logger_Abort2(errno, "Unlocking mutex");
|
if (res) Logger_Abort2(errno, "Unlocking mutex");
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
semaphore_t* ptr = (semaphore_t*)Mem_Alloc(1, sizeof(semaphore_t), "waitable");
|
semaphore_t* ptr = (semaphore_t*)Mem_Alloc(1, sizeof(semaphore_t), "waitable");
|
||||||
int res = sem_init(ptr, 0);
|
int res = sem_init(ptr, 0);
|
||||||
if (res) Logger_Abort2(errno, "Creating waitable");
|
if (res) Logger_Abort2(errno, "Creating waitable");
|
||||||
|
@ -272,7 +272,7 @@ void Thread_Join(void* handle) {
|
|||||||
Mem_Free(ptr);
|
Mem_Free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
mutex_t* ptr = (mutex_t*)Mem_Alloc(1, sizeof(mutex_t), "mutex");
|
mutex_t* ptr = (mutex_t*)Mem_Alloc(1, sizeof(mutex_t), "mutex");
|
||||||
int res = LWP_MutexInit(ptr, false);
|
int res = LWP_MutexInit(ptr, false);
|
||||||
if (res) Logger_Abort2(res, "Creating mutex");
|
if (res) Logger_Abort2(res, "Creating mutex");
|
||||||
@ -305,7 +305,7 @@ struct WaitData {
|
|||||||
int signalled; // For when Waitable_Signal is called before Waitable_Wait
|
int signalled; // For when Waitable_Signal is called before Waitable_Wait
|
||||||
};
|
};
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
struct WaitData* ptr = (struct WaitData*)Mem_Alloc(1, sizeof(struct WaitData), "waitable");
|
struct WaitData* ptr = (struct WaitData*)Mem_Alloc(1, sizeof(struct WaitData), "waitable");
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
@ -248,9 +248,8 @@ void Thread_Join(void* handle) {
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
// TODO
|
return NULL;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mutex_Free(void* handle) {
|
void Mutex_Free(void* handle) {
|
||||||
@ -265,9 +264,8 @@ void Mutex_Unlock(void* handle) {
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
return 1;
|
return NULL;
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Waitable_Free(void* handle) {
|
void Waitable_Free(void* handle) {
|
||||||
|
@ -180,7 +180,7 @@ void Thread_Detach(void* handle) {
|
|||||||
void Thread_Join(void* handle) {
|
void Thread_Join(void* handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ void Mutex_Lock(void* handle) {
|
|||||||
void Mutex_Unlock(void* handle) {
|
void Mutex_Unlock(void* handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ void Thread_Detach(void* handle) {
|
|||||||
void Thread_Join(void* handle) {
|
void Thread_Join(void* handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ void Mutex_Lock(void* handle) {
|
|||||||
void Mutex_Unlock(void* handle) {
|
void Mutex_Unlock(void* handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ void Thread_Detach(void* handle) {
|
|||||||
void Thread_Join(void* handle) {
|
void Thread_Join(void* handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ void Mutex_Lock(void* handle) {
|
|||||||
void Mutex_Unlock(void* handle) {
|
void Mutex_Unlock(void* handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ void Thread_Join(void* handle) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
ee_sema_t sema = { 0 };
|
ee_sema_t sema = { 0 };
|
||||||
sema.init_count = 1;
|
sema.init_count = 1;
|
||||||
sema.max_count = 1;
|
sema.max_count = 1;
|
||||||
@ -307,7 +307,7 @@ void Mutex_Unlock(void* handle) {
|
|||||||
if (res < 0) Logger_Abort2(res, "Unlocking mutex");
|
if (res < 0) Logger_Abort2(res, "Unlocking mutex");
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
ee_sema_t sema = { 0 };
|
ee_sema_t sema = { 0 };
|
||||||
sema.init_count = 0;
|
sema.init_count = 0;
|
||||||
sema.max_count = 1;
|
sema.max_count = 1;
|
||||||
|
@ -260,7 +260,7 @@ void Thread_Join(void* handle) {
|
|||||||
Mem_Free(thread);
|
Mem_Free(thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
sys_mutex_attr_t attr;
|
sys_mutex_attr_t attr;
|
||||||
sysMutexAttrInitialize(attr);
|
sysMutexAttrInitialize(attr);
|
||||||
|
|
||||||
@ -289,7 +289,7 @@ void Mutex_Unlock(void* handle) {
|
|||||||
if (res) Logger_Abort2(res, "Unlocking mutex");
|
if (res) Logger_Abort2(res, "Unlocking mutex");
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
sys_sem_attr_t attr = { 0 };
|
sys_sem_attr_t attr = { 0 };
|
||||||
attr.attr_protocol = SYS_SEM_ATTR_PROTOCOL;
|
attr.attr_protocol = SYS_SEM_ATTR_PROTOCOL;
|
||||||
attr.attr_pshared = SYS_SEM_ATTR_PSHARED;
|
attr.attr_pshared = SYS_SEM_ATTR_PSHARED;
|
||||||
|
@ -239,9 +239,9 @@ void Thread_Join(void* handle) {
|
|||||||
sceKernelDeleteThread((int)handle);
|
sceKernelDeleteThread((int)handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
SceLwMutexWorkarea* ptr = (SceLwMutexWorkarea*)Mem_Alloc(1, sizeof(SceLwMutexWorkarea), "mutex");
|
SceLwMutexWorkarea* ptr = (SceLwMutexWorkarea*)Mem_Alloc(1, sizeof(SceLwMutexWorkarea), "mutex");
|
||||||
int res = sceKernelCreateLwMutex(ptr, "CC mutex", 0, 0, NULL);
|
int res = sceKernelCreateLwMutex(ptr, name, 0, 0, NULL);
|
||||||
if (res) Logger_Abort2(res, "Creating mutex");
|
if (res) Logger_Abort2(res, "Creating mutex");
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
@ -262,8 +262,8 @@ void Mutex_Unlock(void* handle) {
|
|||||||
if (res) Logger_Abort2(res, "Unlocking mutex");
|
if (res) Logger_Abort2(res, "Unlocking mutex");
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
int evid = sceKernelCreateEventFlag("CC event", PSP_EVENT_WAITMULTIPLE, 0, NULL);
|
int evid = sceKernelCreateEventFlag(name, PSP_EVENT_WAITMULTIPLE, 0, NULL);
|
||||||
if (evid < 0) Logger_Abort2(evid, "Creating waitable");
|
if (evid < 0) Logger_Abort2(evid, "Creating waitable");
|
||||||
return (void*)evid;
|
return (void*)evid;
|
||||||
}
|
}
|
||||||
|
@ -222,9 +222,9 @@ void Thread_Join(void* handle) {
|
|||||||
sceKernelDeleteThread((int)handle);
|
sceKernelDeleteThread((int)handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
SceKernelLwMutexWork* ptr = (SceKernelLwMutexWork*)Mem_Alloc(1, sizeof(SceKernelLwMutexWork), "mutex");
|
SceKernelLwMutexWork* ptr = (SceKernelLwMutexWork*)Mem_Alloc(1, sizeof(SceKernelLwMutexWork), "mutex");
|
||||||
int res = sceKernelCreateLwMutex(ptr, "CC mutex", 0, 0, NULL);
|
int res = sceKernelCreateLwMutex(ptr, name, 0, 0, NULL);
|
||||||
if (res) Logger_Abort2(res, "Creating mutex");
|
if (res) Logger_Abort2(res, "Creating mutex");
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
@ -245,8 +245,8 @@ void Mutex_Unlock(void* handle) {
|
|||||||
if (res) Logger_Abort2(res, "Unlocking mutex");
|
if (res) Logger_Abort2(res, "Unlocking mutex");
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
int evid = sceKernelCreateEventFlag("CC event", SCE_EVENT_WAITMULTIPLE, 0, NULL);
|
int evid = sceKernelCreateEventFlag(name, SCE_EVENT_WAITMULTIPLE, 0, NULL);
|
||||||
if (evid < 0) Logger_Abort2(evid, "Creating waitable");
|
if (evid < 0) Logger_Abort2(evid, "Creating waitable");
|
||||||
return (void*)evid;
|
return (void*)evid;
|
||||||
}
|
}
|
||||||
|
@ -389,7 +389,7 @@ void Thread_Join(void* handle) {
|
|||||||
Mem_Free(ptr);
|
Mem_Free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
pthread_mutex_t* ptr = (pthread_mutex_t*)Mem_Alloc(1, sizeof(pthread_mutex_t), "mutex");
|
pthread_mutex_t* ptr = (pthread_mutex_t*)Mem_Alloc(1, sizeof(pthread_mutex_t), "mutex");
|
||||||
int res = pthread_mutex_init(ptr, NULL);
|
int res = pthread_mutex_init(ptr, NULL);
|
||||||
if (res) Logger_Abort2(res, "Creating mutex");
|
if (res) Logger_Abort2(res, "Creating mutex");
|
||||||
@ -418,7 +418,7 @@ struct WaitData {
|
|||||||
int signalled; /* For when Waitable_Signal is called before Waitable_Wait */
|
int signalled; /* For when Waitable_Signal is called before Waitable_Wait */
|
||||||
};
|
};
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
struct WaitData* ptr = (struct WaitData*)Mem_Alloc(1, sizeof(struct WaitData), "waitable");
|
struct WaitData* ptr = (struct WaitData*)Mem_Alloc(1, sizeof(struct WaitData), "waitable");
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ void Thread_Detach(void* handle) {
|
|||||||
void Thread_Join(void* handle) {
|
void Thread_Join(void* handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ void Mutex_Lock(void* handle) {
|
|||||||
void Mutex_Unlock(void* handle) {
|
void Mutex_Unlock(void* handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ void Thread_Join(void* handle) {
|
|||||||
Mem_Free(thread);
|
Mem_Free(thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
Mutex* mutex = (Mutex*)Mem_Alloc(1, sizeof(Mutex), "mutex");
|
Mutex* mutex = (Mutex*)Mem_Alloc(1, sizeof(Mutex), "mutex");
|
||||||
mutexInit(mutex);
|
mutexInit(mutex);
|
||||||
return mutex;
|
return mutex;
|
||||||
@ -277,7 +277,7 @@ struct WaitData {
|
|||||||
int signalled; // For when Waitable_Signal is called before Waitable_Wait
|
int signalled; // For when Waitable_Signal is called before Waitable_Wait
|
||||||
};
|
};
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
struct WaitData* ptr = (struct WaitData*)Mem_Alloc(1, sizeof(struct WaitData), "waitable");
|
struct WaitData* ptr = (struct WaitData*)Mem_Alloc(1, sizeof(struct WaitData), "waitable");
|
||||||
|
|
||||||
mutexInit(&ptr->mutex);
|
mutexInit(&ptr->mutex);
|
||||||
@ -326,7 +326,7 @@ void Waitable_WaitFor(void* handle, cc_uint32 milliseconds) {
|
|||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
LEvent* ptr = (LEvent*)Mem_Alloc(1, sizeof(LEvent), "waitable");
|
LEvent* ptr = (LEvent*)Mem_Alloc(1, sizeof(LEvent), "waitable");
|
||||||
leventInit(ptr, false, true);
|
leventInit(ptr, false, true);
|
||||||
return ptr;
|
return ptr;
|
||||||
|
@ -228,12 +228,12 @@ cc_result File_Length(cc_file file, cc_uint32* len) {
|
|||||||
/* No real threading support with emscripten backend */
|
/* No real threading support with emscripten backend */
|
||||||
void Thread_Sleep(cc_uint32 milliseconds) { }
|
void Thread_Sleep(cc_uint32 milliseconds) { }
|
||||||
|
|
||||||
void* Mutex_Create(void) { return NULL; }
|
void* Mutex_Create(const char* name) { return NULL; }
|
||||||
void Mutex_Free(void* handle) { }
|
void Mutex_Free(void* handle) { }
|
||||||
void Mutex_Lock(void* handle) { }
|
void Mutex_Lock(void* handle) { }
|
||||||
void Mutex_Unlock(void* handle) { }
|
void Mutex_Unlock(void* handle) { }
|
||||||
|
|
||||||
void* Waitable_Create(void) { return NULL; }
|
void* Waitable_Create(const char* name) { return NULL; }
|
||||||
void Waitable_Free(void* handle) { }
|
void Waitable_Free(void* handle) { }
|
||||||
void Waitable_Signal(void* handle) { }
|
void Waitable_Signal(void* handle) { }
|
||||||
void Waitable_Wait(void* handle) { }
|
void Waitable_Wait(void* handle) { }
|
||||||
|
@ -254,10 +254,10 @@ void Thread_Join(void* handle) {
|
|||||||
OSJoinThread((OSThread*)handle, &result);
|
OSJoinThread((OSThread*)handle, &result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
OSFastMutex* mutex = (OSFastMutex*)Mem_Alloc(1, sizeof(OSFastMutex), "mutex");
|
OSFastMutex* mutex = (OSFastMutex*)Mem_Alloc(1, sizeof(OSFastMutex), "mutex");
|
||||||
|
|
||||||
OSFastMutex_Init(mutex, "CC mutex");
|
OSFastMutex_Init(mutex, name);
|
||||||
return mutex;
|
return mutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ void Mutex_Unlock(void* handle) {
|
|||||||
OSFastMutex_Unlock((OSFastMutex*)handle);
|
OSFastMutex_Unlock((OSFastMutex*)handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
OSEvent* event = (OSEvent*)Mem_Alloc(1, sizeof(OSEvent), "waitable");
|
OSEvent* event = (OSEvent*)Mem_Alloc(1, sizeof(OSEvent), "waitable");
|
||||||
|
|
||||||
OSInitEvent(event, false, OS_EVENT_MODE_AUTO);
|
OSInitEvent(event, false, OS_EVENT_MODE_AUTO);
|
||||||
|
@ -351,7 +351,7 @@ void Thread_Join(void* handle) {
|
|||||||
Thread_Detach(handle);
|
Thread_Detach(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
CRITICAL_SECTION* ptr = (CRITICAL_SECTION*)Mem_Alloc(1, sizeof(CRITICAL_SECTION), "mutex");
|
CRITICAL_SECTION* ptr = (CRITICAL_SECTION*)Mem_Alloc(1, sizeof(CRITICAL_SECTION), "mutex");
|
||||||
InitializeCriticalSection(ptr);
|
InitializeCriticalSection(ptr);
|
||||||
return ptr;
|
return ptr;
|
||||||
@ -364,7 +364,7 @@ void Mutex_Free(void* handle) {
|
|||||||
void Mutex_Lock(void* handle) { EnterCriticalSection((CRITICAL_SECTION*)handle); }
|
void Mutex_Lock(void* handle) { EnterCriticalSection((CRITICAL_SECTION*)handle); }
|
||||||
void Mutex_Unlock(void* handle) { LeaveCriticalSection((CRITICAL_SECTION*)handle); }
|
void Mutex_Unlock(void* handle) { LeaveCriticalSection((CRITICAL_SECTION*)handle); }
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
void* handle = CreateEventA(NULL, false, false, NULL);
|
void* handle = CreateEventA(NULL, false, false, NULL);
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
Logger_Abort2(GetLastError(), "Creating waitable");
|
Logger_Abort2(GetLastError(), "Creating waitable");
|
||||||
|
@ -261,7 +261,7 @@ void Thread_Join(void* handle) {
|
|||||||
Thread_Detach(handle);
|
Thread_Detach(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
CRITICAL_SECTION* ptr = (CRITICAL_SECTION*)Mem_Alloc(1, sizeof(CRITICAL_SECTION), "mutex");
|
CRITICAL_SECTION* ptr = (CRITICAL_SECTION*)Mem_Alloc(1, sizeof(CRITICAL_SECTION), "mutex");
|
||||||
RtlInitializeCriticalSection(ptr);
|
RtlInitializeCriticalSection(ptr);
|
||||||
return ptr;
|
return ptr;
|
||||||
@ -280,7 +280,7 @@ void Mutex_Unlock(void* handle) {
|
|||||||
RtlLeaveCriticalSection((CRITICAL_SECTION*)handle);
|
RtlLeaveCriticalSection((CRITICAL_SECTION*)handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
NTSTATUS status = NtCreateEvent(&handle, NULL, SynchronizationEvent, false);
|
NTSTATUS status = NtCreateEvent(&handle, NULL, SynchronizationEvent, false);
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ void Thread_Detach(void* handle) {// TODO
|
|||||||
void Thread_Join(void* handle) {// TODO
|
void Thread_Join(void* handle) {// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mutex_Create(void) {
|
void* Mutex_Create(const char* name) {
|
||||||
return Mem_AllocCleared(1, sizeof(int), "mutex");
|
return Mem_AllocCleared(1, sizeof(int), "mutex");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ void Mutex_Free(void* handle) {
|
|||||||
void Mutex_Lock(void* handle) { } // TODO
|
void Mutex_Lock(void* handle) { } // TODO
|
||||||
void Mutex_Unlock(void* handle) { } // TODO
|
void Mutex_Unlock(void* handle) { } // TODO
|
||||||
|
|
||||||
void* Waitable_Create(void) {
|
void* Waitable_Create(const char* name) {
|
||||||
return NULL; // TODO
|
return NULL; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ static int events_count, events_capacity;
|
|||||||
static CCEvent* events_list, events_default[EVENTS_DEFAULT_MAX];
|
static CCEvent* events_list, events_default[EVENTS_DEFAULT_MAX];
|
||||||
|
|
||||||
static void Events_Init(void) {
|
static void Events_Init(void) {
|
||||||
events_mutex = Mutex_Create();
|
events_mutex = Mutex_Create("BeOS events");
|
||||||
events_capacity = EVENTS_DEFAULT_MAX;
|
events_capacity = EVENTS_DEFAULT_MAX;
|
||||||
events_list = events_default;
|
events_list = events_default;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user