diff options
author | Bjørn Erik Pedersen <[email protected]> | 2020-02-25 21:40:02 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2020-04-07 21:59:20 +0200 |
commit | 2f721f8ec69c52202815cd1b543ca4bf535c0901 (patch) | |
tree | cae7d1ee9ce867a4bffc70e94513f09e2aebe162 /identity | |
parent | 8568928aa8e82a6bd7de4555c3703d8835fbd25b (diff) | |
download | hugo-2f721f8ec69c52202815cd1b543ca4bf535c0901.tar.gz hugo-2f721f8ec69c52202815cd1b543ca4bf535c0901.zip |
Add basic "post resource publish support"
Fixes #7146
Diffstat (limited to 'identity')
-rw-r--r-- | identity/identity.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/identity/identity.go b/identity/identity.go index 7e03120b4..ac3558d16 100644 --- a/identity/identity.go +++ b/identity/identity.go @@ -4,6 +4,7 @@ import ( "path/filepath" "strings" "sync" + "sync/atomic" ) // NewIdentityManager creates a new Manager starting at id. @@ -139,3 +140,18 @@ func (im *identityManager) Search(id Identity) Provider { defer im.Unlock() return im.ids.search(0, id.GetIdentity()) } + +// Incrementer increments and returns the value. +// Typically used for IDs. +type Incrementer interface { + Incr() int +} + +// IncrementByOne implements Incrementer adding 1 every time Incr is called. +type IncrementByOne struct { + counter uint64 +} + +func (c *IncrementByOne) Incr() int { + return int(atomic.AddUint64(&c.counter, uint64(1))) +} |