Skip to content

Commit

Permalink
Use an Arc to internally wrap the SourceMap
Browse files Browse the repository at this point in the history
  • Loading branch information
vcfxb committed Jul 13, 2024
1 parent a55575c commit 0e086de
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions wright/src/source_tracking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ pub mod source;
pub type SourceRef = Arc<Source>;

/// Storage for [Source]s used and referenced in compiling a wright project.
#[derive(Debug, Default)]
///
/// [Clone]ing is cheap, since this uses an [Arc] internally.
#[derive(Debug, Default, Clone)]
pub struct SourceMap {
/// Internally, we use [DashMap] for a concurrent hashmap from [Source::id]s to their [Arc]'d
///
/// Each source is wrapped in an [Arc] to make them all accessible without holding a reference to this map
/// directly.
inner: DashMap<SourceId, SourceRef>,
inner: Arc<DashMap<SourceId, SourceRef>>,
}

impl SourceMap {
Expand Down

0 comments on commit 0e086de

Please sign in to comment.