@@ -21,12 +21,11 @@ use {
21
21
parking_lot:: { Condvar , Mutex } ,
22
22
rayon_core,
23
23
rustc_data_structures:: fx:: FxHashSet ,
24
- rustc_data_structures:: sync:: Lock ,
25
- rustc_data_structures:: sync:: Lrc ,
26
24
rustc_data_structures:: { defer, jobserver} ,
27
25
rustc_span:: DUMMY_SP ,
28
26
std:: iter,
29
27
std:: process,
28
+ std:: sync:: Arc ,
30
29
} ;
31
30
32
31
/// Represents a span and a query key.
@@ -191,7 +190,7 @@ struct QueryWaiter<D: DepKind> {
191
190
query : Option < QueryJobId > ,
192
191
condvar : Condvar ,
193
192
span : Span ,
194
- cycle : Lock < Option < CycleError < D > > > ,
193
+ cycle : Mutex < Option < CycleError < D > > > ,
195
194
}
196
195
197
196
#[ cfg( parallel_compiler) ]
@@ -205,20 +204,20 @@ impl<D: DepKind> QueryWaiter<D> {
205
204
#[ cfg( parallel_compiler) ]
206
205
struct QueryLatchInfo < D : DepKind > {
207
206
complete : bool ,
208
- waiters : Vec < Lrc < QueryWaiter < D > > > ,
207
+ waiters : Vec < Arc < QueryWaiter < D > > > ,
209
208
}
210
209
211
210
#[ cfg( parallel_compiler) ]
212
211
#[ derive( Clone ) ]
213
212
pub ( super ) struct QueryLatch < D : DepKind > {
214
- info : Lrc < Mutex < QueryLatchInfo < D > > > ,
213
+ info : Arc < Mutex < QueryLatchInfo < D > > > ,
215
214
}
216
215
217
216
#[ cfg( parallel_compiler) ]
218
217
impl < D : DepKind > QueryLatch < D > {
219
218
fn new ( ) -> Self {
220
219
QueryLatch {
221
- info : Lrc :: new ( Mutex :: new ( QueryLatchInfo { complete : false , waiters : Vec :: new ( ) } ) ) ,
220
+ info : Arc :: new ( Mutex :: new ( QueryLatchInfo { complete : false , waiters : Vec :: new ( ) } ) ) ,
222
221
}
223
222
}
224
223
@@ -229,11 +228,11 @@ impl<D: DepKind> QueryLatch<D> {
229
228
span : Span ,
230
229
) -> Result < ( ) , CycleError < D > > {
231
230
let waiter =
232
- Lrc :: new ( QueryWaiter { query, span, cycle : Lock :: new ( None ) , condvar : Condvar :: new ( ) } ) ;
231
+ Arc :: new ( QueryWaiter { query, span, cycle : Mutex :: new ( None ) , condvar : Condvar :: new ( ) } ) ;
233
232
self . wait_on_inner ( & waiter) ;
234
233
// FIXME: Get rid of this lock. We have ownership of the QueryWaiter
235
- // although another thread may still have a Lrc reference so we cannot
236
- // use Lrc ::get_mut
234
+ // although another thread may still have a Arc reference so we cannot
235
+ // use Arc ::get_mut
237
236
let mut cycle = waiter. cycle . lock ( ) ;
238
237
match cycle. take ( ) {
239
238
None => Ok ( ( ) ) ,
@@ -242,7 +241,7 @@ impl<D: DepKind> QueryLatch<D> {
242
241
}
243
242
244
243
/// Awaits the caller on this latch by blocking the current thread.
245
- fn wait_on_inner ( & self , waiter : & Lrc < QueryWaiter < D > > ) {
244
+ fn wait_on_inner ( & self , waiter : & Arc < QueryWaiter < D > > ) {
246
245
let mut info = self . info . lock ( ) ;
247
246
if !info. complete {
248
247
// We push the waiter on to the `waiters` list. It can be accessed inside
@@ -276,7 +275,7 @@ impl<D: DepKind> QueryLatch<D> {
276
275
277
276
/// Removes a single waiter from the list of waiters.
278
277
/// This is used to break query cycles.
279
- fn extract_waiter ( & self , waiter : usize ) -> Lrc < QueryWaiter < D > > {
278
+ fn extract_waiter ( & self , waiter : usize ) -> Arc < QueryWaiter < D > > {
280
279
let mut info = self . info . lock ( ) ;
281
280
debug_assert ! ( !info. complete) ;
282
281
// Remove the waiter from the list of waiters
@@ -428,7 +427,7 @@ where
428
427
fn remove_cycle < D : DepKind > (
429
428
query_map : & QueryMap < D > ,
430
429
jobs : & mut Vec < QueryJobId > ,
431
- wakelist : & mut Vec < Lrc < QueryWaiter < D > > > ,
430
+ wakelist : & mut Vec < Arc < QueryWaiter < D > > > ,
432
431
) -> bool {
433
432
let mut visited = FxHashSet :: default ( ) ;
434
433
let mut stack = Vec :: new ( ) ;
0 commit comments