File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -64,8 +64,14 @@ macro_rules! current {
64
64
#[ repr( transparent) ]
65
65
pub struct Task ( pub ( crate ) Opaque < bindings:: task_struct > ) ;
66
66
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
69
75
// synchronised by C code (e.g., `signal_pending`).
70
76
unsafe impl Sync for Task { }
71
77
You can’t perform that action at this time.
0 commit comments