summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-29 17:43:58 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-29 17:43:58 +0000
commitc90ff68d3271b9b7e981152f11db6ea5f4f6061d (patch)
treefc207378fa3f127637821804995477c0ae213f3d /thread.c
parent5e15194561c45b4a123d0945b4de33f0bf2f2fe6 (diff)
* thread.c (rb_thread_schedule_limits): minor optimization.
eliminate machine context saving when running time is enough small. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/thread.c b/thread.c
index 31b9d4fb68..0e10768129 100644
--- a/thread.c
+++ b/thread.c
@@ -1008,15 +1008,13 @@ rb_thread_schedule_limits(unsigned long limits_us)
if (!rb_thread_alone()) {
rb_thread_t *th = GET_THREAD();
- thread_debug("rb_thread_schedule/switch start\n");
-
- RB_GC_SAVE_MACHINE_CONTEXT(th);
-
- if (th->running_time_us >= limits_us)
+ if (th->running_time_us >= limits_us) {
+ thread_debug("rb_thread_schedule/switch start\n");
+ RB_GC_SAVE_MACHINE_CONTEXT(th);
gvl_yield(th->vm, th);
-
- rb_thread_set_current(th);
- thread_debug("rb_thread_schedule/switch done\n");
+ rb_thread_set_current(th);
+ thread_debug("rb_thread_schedule/switch done\n");
+ }
}
}