mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* thread.c (is_ruby_native_thread): check properly. [ruby-dev:31166]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2c5ae0eeba
commit
6fc746d7e3
4 changed files with 46 additions and 5 deletions
|
@ -1,3 +1,7 @@
|
|||
Sat Aug 18 17:40:11 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* thread.c (is_ruby_native_thread): check properly. [ruby-dev:31166]
|
||||
|
||||
Sat Aug 18 16:44:15 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* insnhelper.ci (vm_call_bmethod),
|
||||
|
|
5
thread.c
5
thread.c
|
@ -3002,5 +3002,8 @@ Init_Thread(void)
|
|||
int
|
||||
is_ruby_native_thread(void)
|
||||
{
|
||||
return Qtrue;
|
||||
rb_thread_t *rb_thread_check_ptr(rb_thread_t *ptr);
|
||||
rb_thread_t *th = ruby_thread_from_native();
|
||||
|
||||
return th ? Qtrue : Qfalse;
|
||||
}
|
||||
|
|
|
@ -72,16 +72,34 @@ static void remove_signal_thread_list(rb_thread_t *th);
|
|||
|
||||
static rb_thread_lock_t signal_thread_list_lock;
|
||||
|
||||
static pthread_key_t ruby_native_thread_key;
|
||||
|
||||
static void
|
||||
null_func()
|
||||
{
|
||||
/* null */
|
||||
}
|
||||
|
||||
static void
|
||||
Init_native_thread()
|
||||
static rb_thread_t *
|
||||
ruby_thread_from_native(void)
|
||||
{
|
||||
GET_THREAD()->thread_id = pthread_self();
|
||||
return pthread_getspecific(ruby_native_thread_key);
|
||||
}
|
||||
|
||||
static int
|
||||
ruby_thread_set_native(rb_thread_t *th)
|
||||
{
|
||||
return pthread_setspecific(ruby_native_thread_key, th) == 0;
|
||||
}
|
||||
|
||||
static void
|
||||
Init_native_thread(void)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
|
||||
pthread_key_create(&ruby_native_thread_key, NULL);
|
||||
th->thread_id = pthread_self();
|
||||
ruby_thread_set_native(th);
|
||||
native_mutex_initialize(&signal_thread_list_lock);
|
||||
posix_signal(SIGVTALRM, null_func);
|
||||
}
|
||||
|
|
|
@ -20,10 +20,26 @@
|
|||
#define native_thread_yield() Sleep(0)
|
||||
#define remove_signal_thread_list(th)
|
||||
|
||||
static volatile DWORD ruby_native_thread_key = TLS_OUT_OF_INDEXES;
|
||||
|
||||
static rb_thread_t *
|
||||
ruby_thread_from_native(void)
|
||||
{
|
||||
return TlsGetValue(ruby_native_thread_key);
|
||||
}
|
||||
|
||||
static int
|
||||
ruby_thread_set_native(rb_thread_t *th)
|
||||
{
|
||||
return TlsSetValue(ruby_native_thread_key, th);
|
||||
}
|
||||
|
||||
static void
|
||||
Init_native_thread()
|
||||
Init_native_thread(void)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
|
||||
ruby_native_thread_key = TlsAlloc();
|
||||
DuplicateHandle(GetCurrentProcess(),
|
||||
GetCurrentThread(),
|
||||
GetCurrentProcess(),
|
||||
|
|
Loading…
Reference in a new issue