mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (thread_status_name): separated from
rb_thread_inspect(). return string expression for thread status. * eval.c (rb_thread_status, rb_thread_inspect): use thread_status_name(). * eval.c (rb_thread_priority_set): return the priority not but self. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ef52ffdf61
commit
192b82bf4b
2 changed files with 32 additions and 17 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Tue Oct 9 17:08:00 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
||||
|
||||
* eval.c (thread_status_name): separated from
|
||||
rb_thread_inspect(). return string expression for thread status.
|
||||
|
||||
* eval.c (rb_thread_status, rb_thread_inspect): use
|
||||
thread_status_name().
|
||||
|
||||
* eval.c (rb_thread_priority_set): return the priority not but
|
||||
self.
|
||||
|
||||
Fri Oct 5 15:19:46 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* marshal.c (w_unique): should not dump anonymous class.
|
||||
|
|
38
eval.c
38
eval.c
|
@ -7110,6 +7110,24 @@ struct thread {
|
|||
#define FOREACH_THREAD(x) FOREACH_THREAD_FROM(curr_thread,x)
|
||||
#define END_FOREACH(x) END_FOREACH_FROM(curr_thread,x)
|
||||
|
||||
static const char *
|
||||
thread_status_name(status)
|
||||
enum thread_status status;
|
||||
{
|
||||
switch (status) {
|
||||
case THREAD_RUNNABLE:
|
||||
return "run";
|
||||
case THREAD_STOPPED:
|
||||
return "sleep";
|
||||
case THREAD_TO_KILL:
|
||||
return "aborting";
|
||||
case THREAD_KILLED:
|
||||
return "dead";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
/* $SAFE accessor */
|
||||
void
|
||||
rb_set_safe_level(level)
|
||||
|
@ -8134,7 +8152,7 @@ rb_thread_priority_set(thread, prio)
|
|||
|
||||
th->priority = NUM2INT(prio);
|
||||
rb_thread_schedule();
|
||||
return thread;
|
||||
return prio;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -8486,9 +8504,7 @@ rb_thread_status(thread)
|
|||
return Qfalse;
|
||||
}
|
||||
|
||||
if (th->status == THREAD_STOPPED)
|
||||
return rb_str_new2("sleep");
|
||||
return rb_str_new2("run");
|
||||
return rb_str_new2(thread_status_name(th->status));
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -8777,21 +8793,9 @@ rb_thread_inspect(thread)
|
|||
{
|
||||
char *cname = rb_class2name(CLASS_OF(thread));
|
||||
rb_thread_t th = rb_thread_check(thread);
|
||||
char *status;
|
||||
const char *status = thread_status_name(th->status);
|
||||
VALUE str;
|
||||
|
||||
switch (th->status) {
|
||||
case THREAD_RUNNABLE:
|
||||
status = "run"; break;
|
||||
case THREAD_STOPPED:
|
||||
status = "sleep"; break;
|
||||
case THREAD_TO_KILL:
|
||||
status = "aborting"; break;
|
||||
case THREAD_KILLED:
|
||||
status = "dead"; break;
|
||||
default:
|
||||
status = "unknown"; break;
|
||||
}
|
||||
str = rb_str_new(0, strlen(cname)+7+16+9+1); /* 7:tags 16:addr 9:status 1:nul */
|
||||
sprintf(RSTRING(str)->ptr, "#<%s:0x%lx %s>", cname, thread, status);
|
||||
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
|
||||
|
|
Loading…
Reference in a new issue