@@ -247,9 +247,12 @@ impl Thread {
247247 } ) ?;
248248 let thread = Arc :: get_mut ( & mut arc) . unwrap ( ) ;
249249 // SAFETY: `inner` is pinned behind the `Arc` reference.
250- let inner = unsafe { Pin :: new_unchecked ( & thread. inner ) } ;
250+ let inner = unsafe { Pin :: new_unchecked ( & mut thread. inner ) } ;
251251 kernel:: spinlock_init!( inner, "Thread::inner" ) ;
252- kernel:: condvar_init!( thread. pinned_condvar( ) , "Thread::work_condvar" ) ;
252+
253+ // SAFETY: `work_condvar` is pinned behind the `Arc` reference.
254+ let condvar = unsafe { Pin :: new_unchecked ( & mut thread. work_condvar ) } ;
255+ kernel:: condvar_init!( condvar, "Thread::work_condvar" ) ;
253256 {
254257 let mut inner = arc. inner . lock ( ) ;
255258 inner. set_reply_work ( reply_work) ;
@@ -258,10 +261,6 @@ impl Thread {
258261 Ok ( arc)
259262 }
260263
261- fn pinned_condvar ( & self ) -> Pin < & CondVar > {
262- unsafe { Pin :: new_unchecked ( & self . work_condvar ) }
263- }
264-
265264 pub ( crate ) fn set_current_transaction ( & self , transaction : Arc < Transaction > ) {
266265 self . inner . lock ( ) . current_transaction = Some ( transaction) ;
267266 }
@@ -276,15 +275,14 @@ impl Thread {
276275 }
277276
278277 // Loop waiting only on the local queue (i.e., not registering with the process queue).
279- let cv = self . pinned_condvar ( ) ;
280278 let mut inner = self . inner . lock ( ) ;
281279 loop {
282280 if let Some ( work) = inner. pop_work ( ) {
283281 return Ok ( work) ;
284282 }
285283
286284 inner. looper_flags |= LOOPER_WAITING ;
287- let signal_pending = cv . wait ( & mut inner) ;
285+ let signal_pending = self . work_condvar . wait ( & mut inner) ;
288286 inner. looper_flags &= !LOOPER_WAITING ;
289287
290288 if signal_pending {
@@ -321,15 +319,14 @@ impl Thread {
321319 Either :: Right ( reg) => reg,
322320 } ;
323321
324- let cv = self . pinned_condvar ( ) ;
325322 let mut inner = self . inner . lock ( ) ;
326323 loop {
327324 if let Some ( work) = inner. pop_work ( ) {
328325 return Ok ( work) ;
329326 }
330327
331328 inner. looper_flags |= LOOPER_WAITING ;
332- let signal_pending = cv . wait ( & mut inner) ;
329+ let signal_pending = self . work_condvar . wait ( & mut inner) ;
333330 inner. looper_flags &= !LOOPER_WAITING ;
334331
335332 if signal_pending {
@@ -352,7 +349,7 @@ impl Thread {
352349 }
353350 inner. push_work ( work) ;
354351 }
355- self . pinned_condvar ( ) . notify_one ( ) ;
352+ self . work_condvar . notify_one ( ) ;
356353 Ok ( ( ) )
357354 }
358355
@@ -535,7 +532,7 @@ impl Thread {
535532 }
536533
537534 // Notify the thread now that we've released the inner lock.
538- self . pinned_condvar ( ) . notify_one ( ) ;
535+ self . work_condvar . notify_one ( ) ;
539536 false
540537 }
541538
@@ -779,7 +776,7 @@ impl Thread {
779776
780777 // Now that the lock is no longer held, notify the waiters if we have to.
781778 if notify {
782- self . pinned_condvar ( ) . notify_one ( ) ;
779+ self . work_condvar . notify_one ( ) ;
783780 }
784781 }
785782
@@ -802,7 +799,7 @@ impl Thread {
802799 // Remove epoll items if polling was ever used on the thread.
803800 let poller = self . inner . lock ( ) . looper_flags & LOOPER_POLL != 0 ;
804801 if poller {
805- self . pinned_condvar ( ) . free_waiters ( ) ;
802+ self . work_condvar . free_waiters ( ) ;
806803
807804 unsafe { bindings:: synchronize_rcu ( ) } ;
808805 }
0 commit comments