diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-09-27 12:07:16 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-09-27 12:08:38 +0300 |
commit | 9beee9f6022a745a40537c0b5d26dc8a43d35944 (patch) | |
tree | 67695b2125dd40a2be84feafa0b2443b8c3274e4 /internal/source/domains.go | |
parent | 8e11c9aa018c157966f30a4d809c7ca454d310fa (diff) |
Create a factory method for Domains to handle mutex better
Diffstat (limited to 'internal/source/domains.go')
-rw-r--r-- | internal/source/domains.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/internal/source/domains.go b/internal/source/domains.go index 54a269d8..85646b8a 100644 --- a/internal/source/domains.go +++ b/internal/source/domains.go @@ -13,7 +13,16 @@ import ( // currently reading them from disk. type Domains struct { dm disk.Map - lock sync.RWMutex + lock *sync.RWMutex +} + +// NewDomains is a factory method for domains initializing a mutex. It should +// not initialize `dm` as we later check the readiness by comparing it with a +// nil value. +func NewDomains() *Domains { + return &Domains{ + lock: new(sync.RWMutex), + } } // GetDomain returns a domain from the domains map |