File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -64,8 +64,14 @@ macro_rules! current {
6464#[ repr( transparent) ]
6565pub struct Task ( pub ( crate ) Opaque < bindings:: task_struct > ) ;
6666
67- // SAFETY: It's OK to access `Task` through references from other threads because we're either
68- // accessing properties that don't change (e.g., `pid`, `group_leader`) or that are properly
67+ // SAFETY: By design, the only way to access a `Task` is via the `current` function or via an
68+ // `ARef<Task>` obtained through the `AlwaysRefCounted` impl. This means that the only situation in
69+ // which a `Task` can be accessed mutably is when the refcount drops to zero and the destructor
70+ // runs. It is safe for that to happen on any thread, so it is ok for this type to be `Send`.
71+ unsafe impl Send for Task { }
72+
73+ // SAFETY: It's OK to access `Task` through shared references from other threads because we're
74+ // either accessing properties that don't change (e.g., `pid`, `group_leader`) or that are properly
6975// synchronised by C code (e.g., `signal_pending`).
7076unsafe impl Sync for Task { }
7177
You can’t perform that action at this time.
0 commit comments