Skip to content

Commit

Permalink
Process Fiber finalizer.
Browse files Browse the repository at this point in the history
We do not yet dispose of unreachable but not-yet-completed Fibers.
  • Loading branch information
brixen committed Jun 26, 2016
1 parent 435e0b1 commit faf044a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
14 changes: 12 additions & 2 deletions machine/builtin/fiber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,20 @@ namespace rubinius {
return state->shared().vm_fibers_count(state);
}

void Fiber::finalize(STATE, Fiber* fib) {
void Fiber::finalize(STATE, Fiber* fiber) {
if(state->shared().config.machine_fiber_log_finalizer.value) {
logger::write("fiber: finalizer: %s, %d",
fib->thread_name()->c_str(state), fib->fiber_id()->to_native());
fiber->thread_name()->c_str(state), fiber->fiber_id()->to_native());
}

if(fiber->vm()) {
if(fiber->vm()->zombie_p()) {
VM::discard(state, fiber->vm());
fiber->vm(NULL);
} else {
logger::write("fiber: finalizer: fiber not completed: %s, %d",
fiber->thread_name()->c_str(state), fiber->fiber_id()->to_native());
}
}
}
}
12 changes: 4 additions & 8 deletions machine/builtin/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,10 @@ namespace rubinius {
logger::write("thread: finalizer: %s", thread->vm()->name().c_str());
}

thread->finalize_instance(state);
}

void Thread::finalize_instance(STATE) {
if(vm() && vm()->zombie_p()) {
fiber_mutex_.std::mutex::~mutex();
VM::discard(state, vm());
vm(NULL);
if(thread->vm() && thread->vm()->zombie_p()) {
thread->fiber_mutex().std::mutex::~mutex();
VM::discard(state, thread->vm());
thread->vm(NULL);
}
}

Expand Down
1 change: 0 additions & 1 deletion machine/builtin/thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ namespace rubinius {
static Thread* create(STATE, Class* klass, VM* vm);

static void finalize(STATE, Thread* thread);
void finalize_instance(STATE);

int start_thread(STATE, void* (*function)(void*));
static void* run(void*);
Expand Down

0 comments on commit faf044a

Please sign in to comment.