Skip to content

Commit

Permalink
extended cache comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jbardin committed Oct 14, 2020
1 parent bb76c3b commit e27ecba
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion configs/configschema/decoder_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ var mapLabelNames = []string{"key"}
// Caching these externally rather than within the struct is required because
// Blocks are used by value and copied when working with NestedBlocks, and the
// copying of the value prevents any safe synchronisation of the struct itself.
//
// While we are using the *Block pointer as the cache key, and the Block
// contents are mutable, once a Block is created it is treated as immutable for
// the duration of its life. Because a Block is a representation of a logical
// schema, which cannot change while it's being used, any modifications to the
// schema during execution would be an error.
type specCache struct {
sync.Mutex
specs map[uintptr]hcldec.Spec
Expand All @@ -26,7 +32,7 @@ var decoderSpecCache = specCache{
specs: map[uintptr]hcldec.Spec{},
}

// get returns the Spec associated with the given Block, or nil if none is
// get returns the Spec associated with eth given Block, or nil if non is
// found.
func (s *specCache) get(b *Block) hcldec.Spec {
s.Lock()
Expand Down

0 comments on commit e27ecba

Please sign in to comment.