Skip to content

Commit dec5c3a

Browse files
author
Eric Holk
committed
---
yaml --- r: 3627 b: refs/heads/master c: bc5d6ae h: refs/heads/master i: 3625: d6b6ded 3623: 7b366ae v: v3
1 parent f3d5e60 commit dec5c3a

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: bbdba21b1f3c7dfc4c0bac3525cc35939ae8ca4c
2+
refs/heads/master: bc5d6aefdabc2ee928cb0599c5a8c73799f191ef

trunk/src/rt/rust_scheduler.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,10 @@ rust_scheduler::create_task(rust_task *spawner, const char *name) {
291291
new (this->kernel) rust_task (this, &newborn_tasks, spawner, name);
292292
DLOG(this, task, "created task: " PTR ", spawner: %s, name: %s",
293293
task, spawner ? spawner->name : "null", name);
294-
if(spawner)
294+
if(spawner) {
295295
task->pin(spawner->pinned_on);
296+
task->on_wakeup(spawner->_on_wakeup);
297+
}
296298
newborn_tasks.append(task);
297299
return task;
298300
}

trunk/src/rt/rust_task.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state,
7373
running_on(-1),
7474
pinned_on(-1),
7575
local_region(&sched->srv->local_region),
76-
synchronized_region(&sched->srv->synchronized_region)
76+
synchronized_region(&sched->srv->synchronized_region),
77+
_on_wakeup(NULL)
7778
{
7879
LOGPTR(sched, "new task", (uintptr_t)this);
7980
DLOG(sched, task, "sizeof(task) = %d (0x%x)", sizeof *this, sizeof *this);
@@ -431,6 +432,10 @@ rust_task::wakeup(rust_cond *from) {
431432
I(sched, cond == from);
432433
cond = NULL;
433434
cond_name = "none";
435+
436+
if(_on_wakeup) {
437+
_on_wakeup->on_wakeup();
438+
}
434439
}
435440

436441
void
@@ -541,6 +546,10 @@ void rust_task::unpin() {
541546
pinned_on = -1;
542547
}
543548

549+
void rust_task::on_wakeup(rust_task::wakeup_callback *callback) {
550+
_on_wakeup = callback;
551+
}
552+
544553
//
545554
// Local Variables:
546555
// mode: C++

trunk/src/rt/rust_task.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ rust_task : public maybe_proxy<rust_task>,
8383
memory_region local_region;
8484
memory_region synchronized_region;
8585

86+
class wakeup_callback {
87+
public:
88+
virtual void on_wakeup() = 0;
89+
};
90+
91+
wakeup_callback *_on_wakeup;
92+
8693
// Only a pointer to 'name' is kept, so it must live as long as this task.
8794
rust_task(rust_scheduler *sched,
8895
rust_task_list *state,
@@ -156,6 +163,8 @@ rust_task : public maybe_proxy<rust_task>,
156163
void pin();
157164
void pin(int id);
158165
void unpin();
166+
167+
void on_wakeup(wakeup_callback *callback);
159168
};
160169

161170
//

0 commit comments

Comments
 (0)