@@ -61,7 +61,7 @@ impl JobRef {
61
61
62
62
#[ inline]
63
63
pub ( super ) unsafe fn execute ( self ) {
64
- ( self . execute_fn ) ( self . pointer )
64
+ unsafe { ( self . execute_fn ) ( self . pointer ) }
65
65
}
66
66
}
67
67
97
97
}
98
98
99
99
pub ( super ) unsafe fn as_job_ref ( & self ) -> JobRef {
100
- JobRef :: new ( self )
100
+ unsafe { JobRef :: new ( self ) }
101
101
}
102
102
103
103
pub ( super ) unsafe fn run_inline ( self , stolen : bool ) -> R {
@@ -116,12 +116,16 @@ where
116
116
R : Send ,
117
117
{
118
118
unsafe fn execute ( this : * const ( ) ) {
119
- let this = & * ( this as * const Self ) ;
119
+ let this = unsafe { & * ( this as * const Self ) } ;
120
120
tlv:: set ( this. tlv ) ;
121
121
let abort = unwind:: AbortIfPanic ;
122
- let func = ( * this. func . get ( ) ) . take ( ) . unwrap ( ) ;
123
- ( * this. result . get ( ) ) = JobResult :: call ( func) ;
124
- Latch :: set ( & this. latch ) ;
122
+ let func = unsafe { ( * this. func . get ( ) ) . take ( ) . unwrap ( ) } ;
123
+ unsafe {
124
+ ( * this. result . get ( ) ) = JobResult :: call ( func) ;
125
+ }
126
+ unsafe {
127
+ Latch :: set ( & this. latch ) ;
128
+ }
125
129
mem:: forget ( abort) ;
126
130
}
127
131
}
@@ -152,7 +156,7 @@ where
152
156
/// lifetimes, so it is up to you to ensure that this JobRef
153
157
/// doesn't outlive any data that it closes over.
154
158
pub ( super ) unsafe fn into_job_ref ( self : Box < Self > ) -> JobRef {
155
- JobRef :: new ( Box :: into_raw ( self ) )
159
+ unsafe { JobRef :: new ( Box :: into_raw ( self ) ) }
156
160
}
157
161
158
162
/// Creates a static `JobRef` from this job.
@@ -169,7 +173,7 @@ where
169
173
BODY : FnOnce ( ) + Send ,
170
174
{
171
175
unsafe fn execute ( this : * const ( ) ) {
172
- let this = Box :: from_raw ( this as * mut Self ) ;
176
+ let this = unsafe { Box :: from_raw ( this as * mut Self ) } ;
173
177
tlv:: set ( this. tlv ) ;
174
178
( this. job ) ( ) ;
175
179
}
@@ -196,7 +200,7 @@ where
196
200
/// lifetimes, so it is up to you to ensure that this JobRef
197
201
/// doesn't outlive any data that it closes over.
198
202
pub ( super ) unsafe fn as_job_ref ( this : & Arc < Self > ) -> JobRef {
199
- JobRef :: new ( Arc :: into_raw ( Arc :: clone ( this) ) )
203
+ unsafe { JobRef :: new ( Arc :: into_raw ( Arc :: clone ( this) ) ) }
200
204
}
201
205
202
206
/// Creates a static `JobRef` from this job.
@@ -213,7 +217,7 @@ where
213
217
BODY : Fn ( ) + Send + Sync ,
214
218
{
215
219
unsafe fn execute ( this : * const ( ) ) {
216
- let this = Arc :: from_raw ( this as * mut Self ) ;
220
+ let this = unsafe { Arc :: from_raw ( this as * mut Self ) } ;
217
221
( this. job ) ( ) ;
218
222
}
219
223
}
@@ -254,17 +258,17 @@ impl JobFifo {
254
258
// jobs in a thread's deque may be popped from the back (LIFO) or stolen from the front
255
259
// (FIFO), but either way they will end up popping from the front of this queue.
256
260
self . inner . push ( job_ref) ;
257
- JobRef :: new ( self )
261
+ unsafe { JobRef :: new ( self ) }
258
262
}
259
263
}
260
264
261
265
impl Job for JobFifo {
262
266
unsafe fn execute ( this : * const ( ) ) {
263
267
// We "execute" a queue by executing its first job, FIFO.
264
- let this = & * ( this as * const Self ) ;
268
+ let this = unsafe { & * ( this as * const Self ) } ;
265
269
loop {
266
270
match this. inner . steal ( ) {
267
- Steal :: Success ( job_ref) => break job_ref. execute ( ) ,
271
+ Steal :: Success ( job_ref) => break unsafe { job_ref. execute ( ) } ,
268
272
Steal :: Empty => panic ! ( "FIFO is empty" ) ,
269
273
Steal :: Retry => { }
270
274
}
0 commit comments