diff options
author | Koichi Sasada <[email protected]> | 2020-11-17 16:40:47 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2020-11-18 03:52:41 +0900 |
commit | 5e3259ea7490a2542d78c433eb8c9d44c7819e61 () | |
tree | 1a280e725a2c66ca776086661e3b707fd73f4577 /thread_win32.c | |
parent | 0683912db888b0421ce4c40ad450ccf75ad7e3f4 (diff) |
fix public interface
To make some kind of Ractor related extensions, some functions should be exposed. * include/ruby/thread_native.h * rb_native_mutex_* * rb_native_cond_* * include/ruby/ractor.h * RB_OBJ_SHAREABLE_P(obj) * rb_ractor_shareable_p(obj) * rb_ractor_std*() * rb_cRactor and rm ractor_pub.h and rename srcdir/ractor.h to srcdir/ractor_core.h (to avoid conflict with include/ruby/ractor.h)
Notes: Merged: https://.com/ruby/ruby/pull/3775
-rw-r--r-- | thread_win32.c | 39 |
1 files changed, 14 insertions, 25 deletions
@@ -52,12 +52,12 @@ w32_error(const char *func) } static int -w32_mutex_lock(HANDLE lock) { DWORD result; while (1) { thread_debug("rb_native_mutex_lock: %p\n", lock); - result = w32_wait_events(&lock, 1, INFINITE, 0); switch (result) { case WAIT_OBJECT_0: /* get mutex object */ @@ -70,7 +70,7 @@ w32_mutex_lock(HANDLE lock) return 0; case WAIT_TIMEOUT: thread_debug("timeout mutex: %p\n", lock); - break; case WAIT_ABANDONED: rb_bug("win32_mutex_lock: WAIT_ABANDONED"); break; @@ -97,7 +97,7 @@ w32_mutex_create(void) static void gvl_acquire(rb_global_vm_lock_t *gvl, rb_thread_t *th) { - w32_mutex_lock(gvl->lock); if (GVL_DEBUG) fprintf(stderr, "gvl acquire (%p): acquire\n", th); } @@ -323,41 +323,30 @@ void rb_native_mutex_lock(rb_nativethread_lock_t *lock) { #if USE_WIN32_MUTEX - w32_mutex_lock(lock->mutex); #else EnterCriticalSection(&lock->crit); #endif } -void -rb_native_mutex_unlock(rb_nativethread_lock_t *lock) { #if USE_WIN32_MUTEX - thread_debug("release mutex: %p\n", lock->mutex); - ReleaseMutex(lock->mutex); #else - LeaveCriticalSection(&lock->crit); #endif } -RBIMPL_ATTR_MAYBE_UNUSED() -static int -native_mutex_trylock(rb_nativethread_lock_t *lock) { #if USE_WIN32_MUTEX - int result; - thread_debug("native_mutex_trylock: %p\n", lock->mutex); - result = w32_wait_events(&lock->mutex, 1, 1, 0); - thread_debug("native_mutex_trylock result: %d\n", result); - switch (result) { - case WAIT_OBJECT_0: - return 0; - case WAIT_TIMEOUT: - return EBUSY; - } - return EINVAL; #else - return TryEnterCriticalSection(&lock->crit) == 0; #endif } |