mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-25 22:00:58 +02:00
@@ -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)))
|
||||
}
|
||||
|
Reference in New Issue
Block a user