File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,9 @@ use core::marker::PhantomData;
9
9
10
10
/// Critical section token.
11
11
///
12
- /// Indicates that you are executing code within a critical section.
12
+ /// An instance of this type indicates that the current core is executing code within a critical
13
+ /// section. This means that no interrupts must be enabled that could preempt the currently running
14
+ /// code.
13
15
#[ derive( Clone , Copy ) ]
14
16
pub struct CriticalSection < ' cs > {
15
17
_0 : PhantomData < & ' cs ( ) > ,
@@ -18,8 +20,17 @@ pub struct CriticalSection<'cs> {
18
20
impl < ' cs > CriticalSection < ' cs > {
19
21
/// Creates a critical section token.
20
22
///
21
- /// This method is meant to be used to create safe abstractions rather than
22
- /// meant to be directly used in applications.
23
+ /// This method is meant to be used to create safe abstractions rather than being directly used
24
+ /// in applications.
25
+ ///
26
+ /// # Safety
27
+ ///
28
+ /// This must only be called when the current core is in a critical section. The caller must
29
+ /// ensure that the returned instance will not live beyond the end of the critical section.
30
+ ///
31
+ /// Note that the lifetime `'cs` of the returned instance is unconstrained. User code must not
32
+ /// be able to influence the lifetime picked for this type, since that might cause it to be
33
+ /// inferred to `'static`.
23
34
#[ inline( always) ]
24
35
pub unsafe fn new ( ) -> Self {
25
36
CriticalSection { _0 : PhantomData }
You can’t perform that action at this time.
0 commit comments