mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-06 13:58:40 +00: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:
@@ -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