@@ -61,7 +61,7 @@ impl JobRef {
6161
6262 #[ inline]
6363 pub ( super ) unsafe fn execute ( self ) {
64- ( self . execute_fn ) ( self . pointer )
64+ unsafe { ( self . execute_fn ) ( self . pointer ) }
6565 }
6666}
6767
9797 }
9898
9999 pub ( super ) unsafe fn as_job_ref ( & self ) -> JobRef {
100- JobRef :: new ( self )
100+ unsafe { JobRef :: new ( self ) }
101101 }
102102
103103 pub ( super ) unsafe fn run_inline ( self , stolen : bool ) -> R {
@@ -116,12 +116,16 @@ where
116116 R : Send ,
117117{
118118 unsafe fn execute ( this : * const ( ) ) {
119- let this = & * ( this as * const Self ) ;
119+ let this = unsafe { & * ( this as * const Self ) } ;
120120 tlv:: set ( this. tlv ) ;
121121 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+ }
125129 mem:: forget ( abort) ;
126130 }
127131}
@@ -152,7 +156,7 @@ where
152156 /// lifetimes, so it is up to you to ensure that this JobRef
153157 /// doesn't outlive any data that it closes over.
154158 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 ) ) }
156160 }
157161
158162 /// Creates a static `JobRef` from this job.
@@ -169,7 +173,7 @@ where
169173 BODY : FnOnce ( ) + Send ,
170174{
171175 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 ) } ;
173177 tlv:: set ( this. tlv ) ;
174178 ( this. job ) ( ) ;
175179 }
@@ -196,7 +200,7 @@ where
196200 /// lifetimes, so it is up to you to ensure that this JobRef
197201 /// doesn't outlive any data that it closes over.
198202 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) ) ) }
200204 }
201205
202206 /// Creates a static `JobRef` from this job.
@@ -213,7 +217,7 @@ where
213217 BODY : Fn ( ) + Send + Sync ,
214218{
215219 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 ) } ;
217221 ( this. job ) ( ) ;
218222 }
219223}
@@ -254,17 +258,17 @@ impl JobFifo {
254258 // jobs in a thread's deque may be popped from the back (LIFO) or stolen from the front
255259 // (FIFO), but either way they will end up popping from the front of this queue.
256260 self . inner . push ( job_ref) ;
257- JobRef :: new ( self )
261+ unsafe { JobRef :: new ( self ) }
258262 }
259263}
260264
261265impl Job for JobFifo {
262266 unsafe fn execute ( this : * const ( ) ) {
263267 // 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 ) } ;
265269 loop {
266270 match this. inner . steal ( ) {
267- Steal :: Success ( job_ref) => break job_ref. execute ( ) ,
271+ Steal :: Success ( job_ref) => break unsafe { job_ref. execute ( ) } ,
268272 Steal :: Empty => panic ! ( "FIFO is empty" ) ,
269273 Steal :: Retry => { }
270274 }
0 commit comments