/* * call-seq: * thr.inspect => string * * Dump the name, id, and status of _thr_ to a string. */ static VALUE rb_thread_inspect(thread) VALUE thread; { char *cname = rb_obj_classname(thread); rb_thread_t th = rb_thread_check(thread); const char *status = thread_status_name(th->status); VALUE str; size_t len = strlen(cname)+7+16+9+1; str = rb_str_new(0, len); /* 7:tags 16:addr 9:status 1:nul */ snprintf(RSTRING(str)->ptr, len, "#<%s:0x%lx %s>", cname, thread, status); RSTRING(str)->len = strlen(RSTRING(str)->ptr); OBJ_INFECT(str, thread); return str; }