Skip to content

Commit

Permalink
Remove threads from list when they finish executing.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Jul 9, 2015
1 parent a9fa225 commit 1d60cbe
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion vm/builtin/thread.cpp
Expand Up @@ -329,7 +329,7 @@ namespace rubinius {

shared.gc_independent();

vm->set_zombie();
vm->set_zombie(state);

RUBINIUS_THREAD_STOP(
const_cast<RBX_DTRACE_CHAR_P>(vm->name().c_str()), vm->thread_id(), 0);
Expand Down
3 changes: 3 additions & 0 deletions vm/internal_threads.cpp
Expand Up @@ -39,6 +39,7 @@ namespace rubinius {

thread->run(state);

vm->set_call_frame(0);
thread->thread_running_ = false;

NativeMethod::cleanup_thread(state);
Expand All @@ -48,6 +49,8 @@ namespace rubinius {

shared.gc_independent();

vm->set_zombie(state);

return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions vm/vm.cpp
Expand Up @@ -107,14 +107,14 @@ namespace rubinius {

void VM::discard(STATE, VM* vm) {
vm->saved_call_frame_ = 0;
vm->shared.remove_vm(vm);

state->vm()->metrics().system.threads_destroyed++;

delete vm;
}

void VM::set_zombie() {
void VM::set_zombie(STATE) {
state->shared().remove_vm(this);
thread.set(nil<Thread>());
zombie_ = true;
}
Expand Down
2 changes: 1 addition & 1 deletion vm/vm.hpp
Expand Up @@ -154,7 +154,7 @@ namespace rubinius {
return interrupt_lock_;
}

void set_zombie();
void set_zombie(STATE);

bool zombie_p() {
return zombie_;
Expand Down

0 comments on commit 1d60cbe

Please sign in to comment.