mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-17 17:42:22 -07:00
win32 shared mutex impl and linux stubs
This commit is contained in:
@@ -861,6 +861,32 @@ 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,6 +277,12 @@ 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,6 +1106,40 @@ 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