summaryrefslogtreecommitdiff
path: root/thread_win32.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-16 21:54:42 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-16 21:54:42 +0000
commit0f0311df0a31fce8ceab3ef9dffead0c67629dbe (patch)
treeb2275b92427d8f4120b79f8c29360c2997c3b4d3 /thread_win32.c
parenta3e73d13c1572c7539eff239954f992e9eef9eed (diff)
thread: reduce GET_THREAD calls
This allows native_sleep to use less stack (80 -> 64 bytes on x86-64) for GVL_UNLOCK_BEGIN/END. For future APIs, we will pass `ec` or `th` around anyways, so the BLOCKING_REGION change should be beneficial in the future. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_win32.c')
-rw-r--r--thread_win32.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/thread_win32.c b/thread_win32.c
index ab308905cb..3c6d0e7369 100644
--- a/thread_win32.c
+++ b/thread_win32.c
@@ -210,8 +210,9 @@ int
rb_w32_wait_events(HANDLE *events, int num, DWORD timeout)
{
int ret;
+ rb_thread_t *th = GET_THREAD();
- BLOCKING_REGION(ret = rb_w32_wait_events_blocking(events, num, timeout),
+ BLOCKING_REGION(th, ret = rb_w32_wait_events_blocking(events, num, timeout),
ubf_handle, ruby_thread_from_native(), FALSE);
return ret;
}
@@ -264,8 +265,9 @@ int WINAPI
rb_w32_Sleep(unsigned long msec)
{
int ret;
+ rb_thread_t *th = GET_THREAD();
- BLOCKING_REGION(ret = rb_w32_sleep(msec),
+ BLOCKING_REGION(th, ret = rb_w32_sleep(msec),
ubf_handle, ruby_thread_from_native(), FALSE);
return ret;
}
@@ -276,7 +278,7 @@ native_sleep(rb_thread_t *th, struct timespec *ts)
const volatile DWORD msec = (ts) ?
(DWORD)(ts->tv_sec * 1000 + ts->tv_nsec / 1000000) : INFINITE;
- GVL_UNLOCK_BEGIN();
+ GVL_UNLOCK_BEGIN(th);
{
DWORD ret;
@@ -299,7 +301,7 @@ native_sleep(rb_thread_t *th, struct timespec *ts)
th->unblock.arg = 0;
rb_native_mutex_unlock(&th->interrupt_lock);
}
- GVL_UNLOCK_END();
+ GVL_UNLOCK_END(th);
}
void