Skip to content

Commit faf044a

Browse files
committedJun 26, 2016
Process Fiber finalizer.
We do not yet dispose of unreachable but not-yet-completed Fibers.
1 parent 435e0b1 commit faf044a

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed
 

‎machine/builtin/fiber.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -417,10 +417,20 @@ namespace rubinius {
417417
return state->shared().vm_fibers_count(state);
418418
}
419419

420-
void Fiber::finalize(STATE, Fiber* fib) {
420+
void Fiber::finalize(STATE, Fiber* fiber) {
421421
if(state->shared().config.machine_fiber_log_finalizer.value) {
422422
logger::write("fiber: finalizer: %s, %d",
423-
fib->thread_name()->c_str(state), fib->fiber_id()->to_native());
423+
fiber->thread_name()->c_str(state), fiber->fiber_id()->to_native());
424+
}
425+
426+
if(fiber->vm()) {
427+
if(fiber->vm()->zombie_p()) {
428+
VM::discard(state, fiber->vm());
429+
fiber->vm(NULL);
430+
} else {
431+
logger::write("fiber: finalizer: fiber not completed: %s, %d",
432+
fiber->thread_name()->c_str(state), fiber->fiber_id()->to_native());
433+
}
424434
}
425435
}
426436
}

‎machine/builtin/thread.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,10 @@ namespace rubinius {
112112
logger::write("thread: finalizer: %s", thread->vm()->name().c_str());
113113
}
114114

115-
thread->finalize_instance(state);
116-
}
117-
118-
void Thread::finalize_instance(STATE) {
119-
if(vm() && vm()->zombie_p()) {
120-
fiber_mutex_.std::mutex::~mutex();
121-
VM::discard(state, vm());
122-
vm(NULL);
115+
if(thread->vm() && thread->vm()->zombie_p()) {
116+
thread->fiber_mutex().std::mutex::~mutex();
117+
VM::discard(state, thread->vm());
118+
thread->vm(NULL);
123119
}
124120
}
125121

‎machine/builtin/thread.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ namespace rubinius {
240240
static Thread* create(STATE, Class* klass, VM* vm);
241241

242242
static void finalize(STATE, Thread* thread);
243-
void finalize_instance(STATE);
244243

245244
int start_thread(STATE, void* (*function)(void*));
246245
static void* run(void*);

0 commit comments

Comments
 (0)
Please sign in to comment.