summaryrefslogtreecommitdiffstats
path: root/thread_pthread.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-25 04:16:06 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-25 04:16:06 +0000
commit10575a7ee241c9986822d9cf3e048964b4c8f5ad (patch)
tree586fd664680dab1af107c4867000d4280ff054e7 /thread_pthread.c
parent6fdb6ee1eb644e9b5986f2f532b7016312d3fbde (diff)
downloadruby-10575a7ee241c9986822d9cf3e048964b4c8f5ad.tar.gz
ruby-10575a7ee241c9986822d9cf3e048964b4c8f5ad.tar.xz
ruby-10575a7ee241c9986822d9cf3e048964b4c8f5ad.zip
* vm_core.h, thread.c, cont.c: add RUBY_VM_SET_INTERRUPT(),
RUBY_VM_SET_TIMER_INTERRUPT(), RUBY_VM_INTERRUPTED(). * thread.c, thread_pthread.c, thread_win32.c: fix to ignore time slice event until sleep. * bootstraptest/test_thread.rb: add a test for time limited join test. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index a51146894..5a3770520 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -392,6 +392,7 @@ native_sleep(rb_thread_t *th, struct timeval *tv)
int prev_status = th->status;
struct timespec ts;
struct timeval tvn;
+ struct timeval tve;
if (tv) {
gettimeofday(&tvn, NULL);
@@ -410,15 +411,14 @@ native_sleep(rb_thread_t *th, struct timeval *tv)
GVL_UNLOCK_BEGIN();
{
pthread_mutex_lock(&th->interrupt_lock);
+ th->unblock_function = ubf_pthread_cond_signal;
+ th->unblock_function_arg = th;
- if (th->interrupt_flag) {
+ if (RUBY_VM_INTERRUPTED(th)) {
/* interrupted. return immediate */
thread_debug("native_sleep: interrupted before sleep\n");
}
else {
- th->unblock_function = ubf_pthread_cond_signal;
- th->unblock_function_arg = th;
-
if (tv == 0) {
thread_debug("native_sleep: pthread_cond_wait start\n");
pthread_cond_wait(&th->native_thread_data.sleep_cond,
@@ -433,14 +433,16 @@ native_sleep(rb_thread_t *th, struct timeval *tv)
&th->interrupt_lock, &ts);
thread_debug("native_sleep: pthread_cond_timedwait end (%d)\n", r);
}
- th->unblock_function = 0;
- th->unblock_function_arg = 0;
}
- pthread_mutex_unlock(&th->interrupt_lock);
+ th->unblock_function = 0;
+ th->unblock_function_arg = 0;
+ pthread_mutex_unlock(&th->interrupt_lock);
th->status = prev_status;
}
GVL_UNLOCK_END();
+ RUBY_VM_CHECK_INTS();
+
thread_debug("native_sleep done\n");
}