mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-14 21:41:25 -07:00
yank out shared mutex impl
Initially shared mutex was needed to lock cores so thread pool executes one parallel for at a time but on machine with high core count we cant saturate processor all the time so we switched to shared semaphore and block thread when all cores are busy.
This commit is contained in:
@@ -861,32 +861,6 @@ os_mutex_drop(OS_Handle mutex)
|
||||
pthread_mutex_unlock(&entity->mutex_handle);
|
||||
}
|
||||
|
||||
internal OS_Handle
|
||||
os_shared_mutex_alloc(String8 name)
|
||||
{
|
||||
NotImplemented;
|
||||
OS_Handle handle = {0};
|
||||
return handle;
|
||||
}
|
||||
|
||||
internal void
|
||||
os_shared_mutex_release(OS_Handle mutex)
|
||||
{
|
||||
NotImplemented;
|
||||
}
|
||||
|
||||
internal B32
|
||||
os_shared_mutex_take(OS_Handle mutex, U64 endt_us)
|
||||
{
|
||||
NotImplemented;
|
||||
}
|
||||
|
||||
internal void
|
||||
os_shared_mutex_drop(OS_Handle mutex)
|
||||
{
|
||||
NotImplemented;
|
||||
}
|
||||
|
||||
//- rjf: reader/writer mutexes
|
||||
|
||||
internal OS_Handle
|
||||
|
||||
@@ -277,12 +277,6 @@ internal void os_rw_mutex_drop_r(OS_Handle mutex);
|
||||
internal void os_rw_mutex_take_w(OS_Handle mutex);
|
||||
internal void os_rw_mutex_drop_w(OS_Handle mutex);
|
||||
|
||||
//- shared mutex
|
||||
internal OS_Handle os_shared_mutex_alloc(String8 name);
|
||||
internal void os_shared_mutex_release(OS_Handle mutex);
|
||||
internal B32 os_shared_mutex_take(OS_Handle mutex, U64 endt_us);
|
||||
internal void os_shared_mutex_drop(OS_Handle mutex);
|
||||
|
||||
//- rjf: condition variables
|
||||
internal OS_Handle os_condition_variable_alloc(void);
|
||||
internal void os_condition_variable_release(OS_Handle cv);
|
||||
|
||||
@@ -1106,40 +1106,6 @@ os_mutex_drop(OS_Handle mutex)
|
||||
LeaveCriticalSection(&entity->mutex);
|
||||
}
|
||||
|
||||
internal OS_Handle
|
||||
os_shared_mutex_alloc(String8 name)
|
||||
{
|
||||
Assert(name.size);
|
||||
Temp scratch = scratch_begin(0,0);
|
||||
String16 name16 = str16_from_8(scratch.arena, name);
|
||||
HANDLE handle = CreateMutexW(0, 0, (WCHAR*)name16.str);
|
||||
Assert(handle != 0);
|
||||
OS_Handle mutex = {(U64)handle};
|
||||
scratch_end(scratch);
|
||||
return mutex;
|
||||
}
|
||||
|
||||
internal void
|
||||
os_shared_mutex_release(OS_Handle mutex)
|
||||
{
|
||||
CloseHandle((HANDLE)mutex.u64[0]);
|
||||
}
|
||||
|
||||
internal B32
|
||||
os_shared_mutex_take(OS_Handle mutex, U64 endt_us)
|
||||
{
|
||||
U32 sleep_ms = os_w32_sleep_ms_from_endt_us(endt_us);
|
||||
DWORD wait_result = WaitForSingleObject((HANDLE)mutex.u64[0], sleep_ms);
|
||||
B32 result = (wait_result == WAIT_OBJECT_0);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal void
|
||||
os_shared_mutex_drop(OS_Handle mutex)
|
||||
{
|
||||
ReleaseMutex((HANDLE)mutex.u64[0]);
|
||||
}
|
||||
|
||||
//- rjf: reader/writer mutexes
|
||||
|
||||
internal OS_Handle
|
||||
|
||||
Reference in New Issue
Block a user