From bc5d6aefdabc2ee928cb0599c5a8c73799f191ef Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Wed, 6 Jul 2011 11:10:40 -0700 Subject: Added a task wakeup callback. Closes #599. The callback happens when a task moves from the "blocked" state to the "running" state. The callback is also inherited by child tasks. There is currently only a native API. This code hasn't been heavily exercised yet. --- src/rt/rust_task.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/rt/rust_task.cpp') diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index b2a60dc92bc..87492600524 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -73,7 +73,8 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state, running_on(-1), pinned_on(-1), local_region(&sched->srv->local_region), - synchronized_region(&sched->srv->synchronized_region) + synchronized_region(&sched->srv->synchronized_region), + _on_wakeup(NULL) { LOGPTR(sched, "new task", (uintptr_t)this); DLOG(sched, task, "sizeof(task) = %d (0x%x)", sizeof *this, sizeof *this); @@ -431,6 +432,10 @@ rust_task::wakeup(rust_cond *from) { I(sched, cond == from); cond = NULL; cond_name = "none"; + + if(_on_wakeup) { + _on_wakeup->on_wakeup(); + } } void @@ -541,6 +546,10 @@ void rust_task::unpin() { pinned_on = -1; } +void rust_task::on_wakeup(rust_task::wakeup_callback *callback) { + _on_wakeup = callback; +} + // // Local Variables: // mode: C++ -- cgit 1.4.1-3-g733a5