@@ -33,18 +33,8 @@ fn hash_for_shard<K: Hash>(key: &K) -> u64 {
33
33
hasher. finish ( )
34
34
}
35
35
36
- struct QueryStateShard < K > {
37
- active : FxHashMap < K , QueryResult > ,
38
- }
39
-
40
- impl < K > Default for QueryStateShard < K > {
41
- fn default ( ) -> QueryStateShard < K > {
42
- QueryStateShard { active : Default :: default ( ) }
43
- }
44
- }
45
-
46
36
pub struct QueryState < K > {
47
- shards : Sharded < QueryStateShard < K > > ,
37
+ shards : Sharded < FxHashMap < K , QueryResult > > ,
48
38
}
49
39
50
40
/// Indicates the state of a query for a given key in a query map.
63
53
{
64
54
pub fn all_inactive ( & self ) -> bool {
65
55
let shards = self . shards . lock_shards ( ) ;
66
- shards. iter ( ) . all ( |shard| shard. active . is_empty ( ) )
56
+ shards. iter ( ) . all ( |shard| shard. is_empty ( ) )
67
57
}
68
58
69
59
pub fn try_collect_active_jobs < CTX : Copy > (
76
66
// deadlock handler, and this shouldn't be locked.
77
67
let shards = self . shards . try_lock_shards ( ) ?;
78
68
for shard in shards. iter ( ) {
79
- for ( k, v) in shard. active . iter ( ) {
69
+ for ( k, v) in shard. iter ( ) {
80
70
if let QueryResult :: Started ( ref job) = * v {
81
71
let query = make_query ( tcx, k. clone ( ) ) ;
82
72
jobs. insert ( job. id , QueryJobInfo { query, job : job. clone ( ) } ) ;
@@ -148,7 +138,7 @@ where
148
138
let mut state_lock = state. shards . get_shard_by_value ( & key) . lock ( ) ;
149
139
let lock = & mut * state_lock;
150
140
151
- match lock. active . entry ( key) {
141
+ match lock. entry ( key) {
152
142
Entry :: Vacant ( entry) => {
153
143
let id = tcx. next_job_id ( ) ;
154
144
let job = tcx. current_query_job ( ) ;
@@ -220,7 +210,7 @@ where
220
210
let shard = get_shard_index_by_hash ( key_hash) ;
221
211
let job = {
222
212
let mut lock = state. shards . get_shard_by_index ( shard) . lock ( ) ;
223
- match lock. active . remove ( & key) . unwrap ( ) {
213
+ match lock. remove ( & key) . unwrap ( ) {
224
214
QueryResult :: Started ( job) => job,
225
215
QueryResult :: Poisoned => panic ! ( ) ,
226
216
}
@@ -246,11 +236,11 @@ where
246
236
let shard = state. shards . get_shard_by_value ( & self . key ) ;
247
237
let job = {
248
238
let mut shard = shard. lock ( ) ;
249
- let job = match shard. active . remove ( & self . key ) . unwrap ( ) {
239
+ let job = match shard. remove ( & self . key ) . unwrap ( ) {
250
240
QueryResult :: Started ( job) => job,
251
241
QueryResult :: Poisoned => panic ! ( ) ,
252
242
} ;
253
- shard. active . insert ( self . key . clone ( ) , QueryResult :: Poisoned ) ;
243
+ shard. insert ( self . key . clone ( ) , QueryResult :: Poisoned ) ;
254
244
job
255
245
} ;
256
246
// Also signal the completion of the job, so waiters
0 commit comments