File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -89,21 +89,23 @@ pub struct CrateMetadata {
89
89
}
90
90
91
91
pub struct CStore {
92
- metas : RefCell < IndexVec < CrateNum , Option < Lrc < CrateMetadata > > > > ,
92
+ metas : RwLock < IndexVec < CrateNum , Option < Lrc < CrateMetadata > > > > ,
93
93
/// Map from NodeId's of local extern crate statements to crate numbers
94
- extern_mod_crate_map : RefCell < NodeMap < CrateNum > > ,
94
+ extern_mod_crate_map : Lock < NodeMap < CrateNum > > ,
95
95
pub metadata_loader : Box < MetadataLoader + Sync > ,
96
96
}
97
97
98
98
impl CStore {
99
99
pub fn new ( metadata_loader : Box < MetadataLoader + Sync > ) -> CStore {
100
100
CStore {
101
- metas : RefCell :: new ( IndexVec :: new ( ) ) ,
102
- extern_mod_crate_map : RefCell :: new ( FxHashMap ( ) ) ,
101
+ metas : RwLock :: new ( IndexVec :: new ( ) ) ,
102
+ extern_mod_crate_map : Lock :: new ( FxHashMap ( ) ) ,
103
103
metadata_loader,
104
104
}
105
105
}
106
106
107
+ /// You cannot use this function to allocate a CrateNum in a thread-safe manner.
108
+ /// It is currently only used in CrateLoader which is single-threaded code.
107
109
pub fn next_crate_num ( & self ) -> CrateNum {
108
110
CrateNum :: new ( self . metas . borrow ( ) . len ( ) + 1 )
109
111
}
You can’t perform that action at this time.
0 commit comments