Skip to content

Commit 1fca8da

Browse files
committed
More safety comments
1 parent 6c2b11c commit 1fca8da

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/static_executors.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ impl LocalExecutor<'static> {
9494
std::mem::forget(self);
9595

9696
{
97+
// SAFETY: All UnsafeCell accesses to active are tightly scoped, and because
98+
// `LocalExecutor` is !Send, there is no way to have concurrent access to the
99+
// values in `State`, including the active field.
97100
let active = unsafe { &mut *state.active.get() };
98101
if !active.is_empty() {
99102
// Reschedule all of the active tasks.
@@ -500,9 +503,11 @@ impl StaticLocalExecutor {
500503
/// Returns a function that schedules a runnable task when it gets woken up.
501504
fn schedule(&'static self) -> impl Fn(Runnable) + 'static {
502505
let state: &'static LocalState = &self.state;
503-
// TODO: If possible, push into the current local queue and notify the ticker.
504506
move |runnable| {
505507
{
508+
// SAFETY: All UnsafeCell accesses to queue are tightly scoped, and because
509+
// `LocalExecutor` is !Send, there is no way to have concurrent access to the
510+
// values in `State`, including the queue field.
506511
let queue = unsafe { &mut *state.queue.get() };
507512
queue.push_front(runnable);
508513
}

0 commit comments

Comments
 (0)