Reintroduce linked failure (renaming runtime fns)

This reverts commit 3b159c6d5b.
This commit is contained in:
Ben Blum 2012-07-12 19:52:21 -04:00
parent 79a2e9a38a
commit aad184cc57
2 changed files with 19 additions and 19 deletions

View file

@ -231,11 +231,11 @@ void rust_task::start()
bool
rust_task::must_fail_from_being_killed() {
scoped_lock with(lifecycle_lock);
return must_fail_from_being_killed_unlocked();
return must_fail_from_being_killed_inner();
}
bool
rust_task::must_fail_from_being_killed_unlocked() {
rust_task::must_fail_from_being_killed_inner() {
lifecycle_lock.must_have_lock();
return killed && !reentered_rust_stack && disallow_kill == 0;
}
@ -275,8 +275,8 @@ rust_task::kill() {
// Unblock the task so it can unwind.
if (state == task_state_blocked &&
must_fail_from_being_killed_unlocked()) {
wakeup_locked(cond);
must_fail_from_being_killed_inner()) {
wakeup_inner(cond);
}
LOG(this, task, "preparing to unwind task: 0x%" PRIxPTR, this);
@ -377,10 +377,10 @@ void
rust_task::transition(rust_task_state src, rust_task_state dst,
rust_cond *cond, const char* cond_name) {
scoped_lock with(lifecycle_lock);
transition_locked(src, dst, cond, cond_name);
transition_inner(src, dst, cond, cond_name);
}
void rust_task::transition_locked(rust_task_state src, rust_task_state dst,
void rust_task::transition_inner(rust_task_state src, rust_task_state dst,
rust_cond *cond, const char* cond_name) {
lifecycle_lock.must_have_lock();
sched_loop->transition(this, src, dst, cond, cond_name);
@ -398,12 +398,12 @@ rust_task::set_state(rust_task_state state,
bool
rust_task::block(rust_cond *on, const char* name) {
scoped_lock with(lifecycle_lock);
return block_locked(on, name);
return block_inner(on, name);
}
bool
rust_task::block_locked(rust_cond *on, const char* name) {
if (must_fail_from_being_killed_unlocked()) {
rust_task::block_inner(rust_cond *on, const char* name) {
if (must_fail_from_being_killed_inner()) {
// We're already going to die. Don't block. Tell the task to fail
return false;
}
@ -413,7 +413,7 @@ rust_task::block_locked(rust_cond *on, const char* name) {
assert(cond == NULL && "Cannot block an already blocked task.");
assert(on != NULL && "Cannot block on a NULL object.");
transition_locked(task_state_running, task_state_blocked, on, name);
transition_inner(task_state_running, task_state_blocked, on, name);
return true;
}
@ -421,17 +421,17 @@ rust_task::block_locked(rust_cond *on, const char* name) {
void
rust_task::wakeup(rust_cond *from) {
scoped_lock with(lifecycle_lock);
wakeup_locked(from);
wakeup_inner(from);
}
void
rust_task::wakeup_locked(rust_cond *from) {
rust_task::wakeup_inner(rust_cond *from) {
assert(cond != NULL && "Cannot wake up unblocked task.");
LOG(this, task, "Blocked on 0x%" PRIxPTR " woken up on 0x%" PRIxPTR,
(uintptr_t) cond, (uintptr_t) from);
assert(cond == from && "Cannot wake up blocked task on wrong condition.");
transition_locked(task_state_blocked, task_state_running, NULL, "none");
transition_inner(task_state_blocked, task_state_running, NULL, "none");
}
void
@ -685,7 +685,7 @@ rust_task::wait_event(bool *killed) {
scoped_lock with(lifecycle_lock);
if(!event_reject) {
block_locked(&event_cond, "waiting on event");
block_inner(&event_cond, "waiting on event");
lifecycle_lock.unlock();
yield(killed);
lifecycle_lock.lock();
@ -702,7 +702,7 @@ rust_task::signal_event(void *event) {
this->event = event;
event_reject = true;
if(task_state_blocked == state) {
wakeup_locked(&event_cond);
wakeup_inner(&event_cond);
}
}

View file

@ -208,10 +208,10 @@ private:
void transition(rust_task_state src, rust_task_state dst,
rust_cond *cond, const char* cond_name);
void transition_locked(rust_task_state src, rust_task_state dst,
void transition_inner(rust_task_state src, rust_task_state dst,
rust_cond *cond, const char* cond_name);
bool must_fail_from_being_killed_unlocked();
bool must_fail_from_being_killed_inner();
// Called by rust_task_fail to unwind on failure
void begin_failure(char const *expr,
char const *file,
@ -226,8 +226,8 @@ private:
char const *file,
size_t line);
bool block_locked(rust_cond *on, const char* name);
void wakeup_locked(rust_cond *from);
bool block_inner(rust_cond *on, const char* name);
void wakeup_inner(rust_cond *from);
public: