Skip to content

Commit

Permalink
Use LockGuards where appropriate as RAII
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun committed Sep 27, 2012
1 parent 0fcb78a commit 27e3de4
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions vm/builtin/thread.cpp
Expand Up @@ -322,20 +322,18 @@ namespace rubinius {
}

Object* Thread::raise(STATE, GCToken gct, Exception* exc) {
init_lock_.lock();
utilities::thread::SpinLock::LockGuard lg(init_lock_);
Thread* self = this;
OnStack<2> os(state, self, exc);

VM* vm = self->vm_;
if(!vm) {
self->init_lock_.unlock();
return cNil;
}

vm->register_raise(state, exc);

vm->wakeup(state, gct);
self->init_lock_.unlock();
return exc;
}

Expand All @@ -344,19 +342,17 @@ namespace rubinius {
}

Thread* Thread::wakeup(STATE, GCToken gct) {
init_lock_.lock();
utilities::thread::SpinLock::LockGuard lg(init_lock_);
Thread* self = this;
OnStack<1> os(state, self);

VM* vm = self->vm_;
if(alive() == cFalse || !vm) {
self->init_lock_.unlock();
return force_as<Thread>(Primitives::failure());
}

vm->wakeup(state, gct);

self->init_lock_.unlock();
return self;
}

Expand Down

0 comments on commit 27e3de4

Please sign in to comment.