Project

General

Profile

Feature #11098 » thread-local-update.patch

jasonrclark (Jason Clark), 04/27/2016 06:06 PM

View differences:

gc.c
#endif
objspace->total_allocated_objects++;
GET_THREAD()->allocated_objects++;
gc_report(5, objspace, "newobj: %s\n", obj_info(obj));
test/ruby/test_thread.rb
c = Class.new(Thread) {def initialize() self.name = "foo"; super; end}
assert_equal("foo", c.new {Thread.current.name}.value)
end
def test_thread_allocated_objects
t = Thread.new do
1000.times do
Object.new
end
end
t.join
assert_equal 1001, t.allocated_objects
end
end
thread.c
return group;
}
VALUE
rb_thread_allocated_objects(VALUE thread)
{
rb_thread_t *th;
GetThreadPtr(thread, th);
return LONG2NUM(th->allocated_objects);
}
static const char *
thread_status_name(rb_thread_t *th)
{
......
rb_define_method(rb_cThread, "abort_on_exception=", rb_thread_abort_exc_set, 1);
rb_define_method(rb_cThread, "safe_level", rb_thread_safe_level, 0);
rb_define_method(rb_cThread, "group", rb_thread_group, 0);
rb_define_method(rb_cThread, "allocated_objects", rb_thread_allocated_objects, 0);
rb_define_method(rb_cThread, "backtrace", rb_thread_backtrace_m, -1);
rb_define_method(rb_cThread, "backtrace_locations", rb_thread_backtrace_locations_m, -1);
vm_core.h
int safe_level;
int raised_flag;
VALUE last_status; /* $? */
uint64_t allocated_objects;
/* passing state */
int state;
(2-2/2)