mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* thread.c (thread_initialize): NUM2INT() returns int.
* thread.c (timer_thread_function), thread_pthread.c (thread_timer),
  thread_win32.c (timer_thread_func), thread_{pthread,win32}.c
  (rb_thread_create_timer_thread): passing VM.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
			
			
This commit is contained in:
		
							parent
							
								
									2ca7298386
								
							
						
					
					
						commit
						6bbbf9889d
					
				
					 4 changed files with 16 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,11 @@
 | 
			
		|||
Sat Jul  5 22:22:27 2008  Nobuyoshi Nakada  <nobu@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* thread.c (thread_initialize): NUM2INT() returns int.
 | 
			
		||||
 | 
			
		||||
	* thread.c (timer_thread_function), thread_pthread.c (thread_timer),
 | 
			
		||||
	  thread_win32.c (timer_thread_func), thread_{pthread,win32}.c
 | 
			
		||||
	  (rb_thread_create_timer_thread): passing VM.
 | 
			
		||||
 | 
			
		||||
Sat Jul  5 20:53:18 2008  Masaki Suketa  <masaki.suketa@nifty.ne.jp>
 | 
			
		||||
 | 
			
		||||
	* test/win32ole/test_word.rb: check word installed.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										7
									
								
								thread.c
									
										
									
									
									
								
							
							
						
						
									
										7
									
								
								thread.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -151,6 +151,7 @@ rb_thread_s_debug_set(VALUE self, VALUE val)
 | 
			
		|||
#endif
 | 
			
		||||
NOINLINE(static int thread_start_func_2(rb_thread_t *th, VALUE *stack_start,
 | 
			
		||||
					VALUE *register_stack_start));
 | 
			
		||||
static void timer_thread_function(void *);
 | 
			
		||||
 | 
			
		||||
#if   defined(_WIN32)
 | 
			
		||||
#include "thread_win32.c"
 | 
			
		||||
| 
						 | 
				
			
			@ -490,7 +491,7 @@ thread_initialize(VALUE thread, VALUE args)
 | 
			
		|||
	    rb_raise(rb_eThreadError, "already initialized thread - %s",
 | 
			
		||||
		     file);
 | 
			
		||||
	}
 | 
			
		||||
        rb_raise(rb_eThreadError, "already initialized thread - %s:%ld",
 | 
			
		||||
        rb_raise(rb_eThreadError, "already initialized thread - %s:%d",
 | 
			
		||||
                 file, NUM2INT(line));
 | 
			
		||||
    }
 | 
			
		||||
    return thread_create_core(thread, args, 0);
 | 
			
		||||
| 
						 | 
				
			
			@ -2050,9 +2051,9 @@ rb_gc_save_machine_context(rb_thread_t *th)
 | 
			
		|||
int rb_get_next_signal(rb_vm_t *vm);
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
timer_thread_function(void)
 | 
			
		||||
timer_thread_function(void *arg)
 | 
			
		||||
{
 | 
			
		||||
    rb_vm_t *vm = GET_VM(); /* TODO: fix me for Multi-VM */
 | 
			
		||||
    rb_vm_t *vm = arg; /* TODO: fix me for Multi-VM */
 | 
			
		||||
 | 
			
		||||
    /* for time slice */
 | 
			
		||||
    RUBY_VM_SET_TIMER_INTERRUPT(vm->running_thread);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -641,7 +641,6 @@ remove_signal_thread_list(rb_thread_t *th)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static pthread_t timer_thread_id;
 | 
			
		||||
static void timer_thread_function(void);
 | 
			
		||||
 | 
			
		||||
static void *
 | 
			
		||||
thread_timer(void *dummy)
 | 
			
		||||
| 
						 | 
				
			
			@ -670,7 +669,7 @@ thread_timer(void *dummy)
 | 
			
		|||
	    });
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
	timer_thread_function();
 | 
			
		||||
	timer_thread_function(dummy);
 | 
			
		||||
    }
 | 
			
		||||
    return NULL;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -688,7 +687,7 @@ rb_thread_create_timer_thread(void)
 | 
			
		|||
#ifdef PTHREAD_STACK_MIN
 | 
			
		||||
	pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN);
 | 
			
		||||
#endif
 | 
			
		||||
	err = pthread_create(&timer_thread_id, &attr, thread_timer, 0);
 | 
			
		||||
	err = pthread_create(&timer_thread_id, &attr, thread_timer, GET_VM());
 | 
			
		||||
	if (err != 0) {
 | 
			
		||||
	    rb_bug("rb_thread_create_timer_thread: return non-zero (%d)", err);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -537,8 +537,6 @@ ubf_handle(void *ptr)
 | 
			
		|||
    w32_set_event(th->native_thread_data.interrupt_event);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void timer_thread_function(void);
 | 
			
		||||
 | 
			
		||||
static HANDLE timer_thread_id = 0;
 | 
			
		||||
 | 
			
		||||
static unsigned long _stdcall
 | 
			
		||||
| 
						 | 
				
			
			@ -547,7 +545,7 @@ timer_thread_func(void *dummy)
 | 
			
		|||
    thread_debug("timer_thread\n");
 | 
			
		||||
    while (system_working) {
 | 
			
		||||
	Sleep(WIN32_WAIT_TIMEOUT);
 | 
			
		||||
	timer_thread_function();
 | 
			
		||||
	timer_thread_function(dummy);
 | 
			
		||||
    }
 | 
			
		||||
    thread_debug("timer killed\n");
 | 
			
		||||
    return 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -557,7 +555,7 @@ void
 | 
			
		|||
rb_thread_create_timer_thread(void)
 | 
			
		||||
{
 | 
			
		||||
    if (timer_thread_id == 0) {
 | 
			
		||||
	timer_thread_id = w32_create_thread(1024, timer_thread_func, 0);
 | 
			
		||||
	timer_thread_id = w32_create_thread(1024, timer_thread_func, GET_VM());
 | 
			
		||||
	w32_resume_thread(timer_thread_id);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue