From: Eric Wong Date: 2014-12-26T21:49:10+00:00 Subject: [ruby-core:67155] Re: [ruby-trunk - Feature #10658] [Open] ThreadGroup local variables godfat@godfat.org wrote: > * What I was doing before: Assume ThreadGroup#list.first is the owner of > the group, thus the worker thread, and use that thread to store the number. > Something like: > > Thread.current.group.list.first[:assertions] += 1 > > This works for Ruby 1.9, 2.0, 2.1, but not for 2.2. > This also works for Rubinius. I thought this is somehow an expected behaviour, > therefore did a patch for JRuby to make this work: > https://github.com/jruby/jruby/pull/2221 > Until now it failed on Ruby 2.2, did I know the order was not preserved... Oops, can you try the following? --- a/vm_core.h +++ b/vm_core.h @@ -975,7 +975,7 @@ rb_vm_living_threads_init(rb_vm_t *vm) static inline void rb_vm_living_threads_insert(rb_vm_t *vm, rb_thread_t *th) { - list_add(&vm->living_threads, &th->vmlt_node); + list_add_tail(&vm->living_threads, &th->vmlt_node); vm->living_thread_num++; } Ordering is preserved, just backwards. But I am unsure if order should be spec which is relied on...