diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-06-12 11:48:12 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-06-12 11:48:12 +0100 |
| commit | 8fafdb185cefee691e1c2e1990abf8cd3c97ddf4 (patch) | |
| tree | 8422ecb57d2d4f830ca6b76f54f0ad1a2f19f2a7 /core/sync_linux.odin | |
| parent | c2c935ba818167a7056da5ac61687ecd2d97cc59 (diff) | |
Remove := with var and :: with const
Diffstat (limited to 'core/sync_linux.odin')
| -rw-r--r-- | core/sync_linux.odin | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/core/sync_linux.odin b/core/sync_linux.odin index 4b0e0da2e..4ed1d42f1 100644 --- a/core/sync_linux.odin +++ b/core/sync_linux.odin @@ -1,53 +1,53 @@ #import "atomics.odin"; #import "os.odin"; -Semaphore :: struct { +const Semaphore = struct { // _handle: win32.Handle, } -Mutex :: struct { +const Mutex = struct { _semaphore: Semaphore, _counter: i32, _owner: i32, _recursion: i32, } -current_thread_id :: proc() -> i32 { +const current_thread_id = proc() -> i32 { return i32(os.current_thread_id()); } -semaphore_init :: proc(s: ^Semaphore) { +const semaphore_init = proc(s: ^Semaphore) { // s._handle = win32.CreateSemaphoreA(nil, 0, 1<<31-1, nil); } -semaphore_destroy :: proc(s: ^Semaphore) { +const semaphore_destroy = proc(s: ^Semaphore) { // win32.CloseHandle(s._handle); } -semaphore_post :: proc(s: ^Semaphore, count: int) { +const semaphore_post = proc(s: ^Semaphore, count: int) { // win32.ReleaseSemaphore(s._handle, cast(i32)count, nil); } -semaphore_release :: proc(s: ^Semaphore) #inline { +const semaphore_release = proc(s: ^Semaphore) #inline { semaphore_post(s, 1); } -semaphore_wait :: proc(s: ^Semaphore) { +const semaphore_wait = proc(s: ^Semaphore) { // win32.WaitForSingleObject(s._handle, win32.INFINITE); } -mutex_init :: proc(m: ^Mutex) { +const mutex_init = proc(m: ^Mutex) { atomics.store(&m._counter, 0); atomics.store(&m._owner, current_thread_id()); semaphore_init(&m._semaphore); m._recursion = 0; } -mutex_destroy :: proc(m: ^Mutex) { +const mutex_destroy = proc(m: ^Mutex) { semaphore_destroy(&m._semaphore); } -mutex_lock :: proc(m: ^Mutex) { - thread_id := current_thread_id(); +const mutex_lock = proc(m: ^Mutex) { + var thread_id = current_thread_id(); if atomics.fetch_add(&m._counter, 1) > 0 { if thread_id != atomics.load(&m._owner) { semaphore_wait(&m._semaphore); @@ -56,12 +56,12 @@ mutex_lock :: proc(m: ^Mutex) { atomics.store(&m._owner, thread_id); m._recursion++; } -mutex_try_lock :: proc(m: ^Mutex) -> bool { - thread_id := current_thread_id(); +const mutex_try_lock = proc(m: ^Mutex) -> bool { + var thread_id = current_thread_id(); if atomics.load(&m._owner) == thread_id { atomics.fetch_add(&m._counter, 1); } else { - expected: i32 = 0; + var expected: i32 = 0; if atomics.load(&m._counter) != 0 { return false; } @@ -73,9 +73,9 @@ mutex_try_lock :: proc(m: ^Mutex) -> bool { m._recursion++; return true; } -mutex_unlock :: proc(m: ^Mutex) { - recursion: i32; - thread_id := current_thread_id(); +const mutex_unlock = proc(m: ^Mutex) { + var recursion: i32; + var thread_id = current_thread_id(); assert(thread_id == atomics.load(&m._owner)); m._recursion--; |