Skip to content

Commit d756b01

Browse files
committed
rt: Add a function for configuring task notification
1 parent e0d5b92 commit d756b01

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

src/rt/rust_builtin.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,16 @@ drop_task(rust_task *target) {
481481
}
482482
}
483483

484+
extern "C" CDECL void
485+
rust_task_config_notify(rust_task_id task_id, chan_handle *chan) {
486+
rust_task *task = rust_task_thread::get_task();
487+
rust_task *target = task->kernel->get_task_by_id(task_id);
488+
A(task->thread, target != NULL,
489+
"This function should only be called when we know the task exists");
490+
target->config_notify(*chan);
491+
target->deref();
492+
}
493+
484494
extern "C" CDECL rust_task *
485495
get_task_pointer(rust_task_id id) {
486496
rust_task *task = rust_task_thread::get_task();

src/rt/rust_task.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,12 @@ rust_task::check_stack_canary() {
713713
::check_stack_canary(stk);
714714
}
715715

716+
void
717+
rust_task::config_notify(chan_handle chan) {
718+
user.notify_enabled = true;
719+
user.notify_chan = chan;
720+
}
721+
716722
//
717723
// Local Variables:
718724
// mode: C++

src/rt/rust_task.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ rust_task : public kernel_owned<rust_task>, rust_cond
181181
void reset_stack_limit();
182182
bool on_rust_stack();
183183
void check_stack_canary();
184+
185+
void config_notify(chan_handle chan);
184186
};
185187

186188
//

src/rt/rustrt.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ rust_env_pairs
4949
rust_task_yield
5050
rust_task_is_unwinding
5151
rust_get_task
52+
rust_task_config_notify
5253
sched_threads
5354
shape_log_str
5455
squareroot

0 commit comments

Comments
 (0)