From 2f721f8ec69c52202815cd1b543ca4bf535c0901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Tue, 25 Feb 2020 21:40:02 +0100 Subject: Add basic "post resource publish support" Fixes #7146 --- identity/identity.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'identity/identity.go') 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))) +} -- cgit v1.2.3