Skip to content

Commit

Permalink
Fix comments for the ID manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Nov 7, 2019
1 parent f8c40e7 commit 075cae8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/skycoin/dmsg v0.0.0-20190805065636-70f4c32a994f/go.mod h1:obZYZp8eKR7Xqz+KNhJdUE6Gvp6rEXbDO8YTlW2YXgU=
github.com/skycoin/skycoin v0.26.0 h1:xDxe2r8AclMntZ550Y/vUQgwgLtwrf9Wu5UYiYcN5/o=
github.com/skycoin/skycoin v0.26.0/go.mod h1:78nHjQzd8KG0jJJVL/j0xMmrihXi70ti63fh8vXScJw=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
Expand Down
14 changes: 7 additions & 7 deletions pkg/app2/idmanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ type Manager struct {
lstID uint16
}

// NewIDManager constructs new `Manager`.
// New constructs new `Manager`.
func New() *Manager {
return &Manager{
values: make(map[uint16]interface{}),
}
}

// `ReserveNextID` reserves next free slot for the value and returns the id for it.
// ReserveNextID reserves next free slot for the value and returns the id for it.
func (m *Manager) ReserveNextID() (id *uint16, free func() bool, err error) {
m.mx.Lock()

Expand All @@ -53,7 +53,7 @@ func (m *Manager) ReserveNextID() (id *uint16, free func() bool, err error) {
return &nxtID, m.constructFreeFunc(nxtID), nil
}

// pop removes value specified by `id` from the idManager instance and
// Pop removes value specified by `id` from the idManager instance and
// returns it.
func (m *Manager) Pop(id uint16) (interface{}, error) {
m.mx.Lock()
Expand All @@ -74,7 +74,7 @@ func (m *Manager) Pop(id uint16) (interface{}, error) {
return v, nil
}

// add adds the new value `v` associated with `id`.
// Add adds the new value `v` associated with `id`.
func (m *Manager) Add(id uint16, v interface{}) (free func() bool, err error) {
m.mx.Lock()

Expand All @@ -89,7 +89,7 @@ func (m *Manager) Add(id uint16, v interface{}) (free func() bool, err error) {
return m.constructFreeFunc(id), nil
}

// set sets value `v` associated with `id`.
// Set sets value `v` associated with `id`.
func (m *Manager) Set(id uint16, v interface{}) error {
m.mx.Lock()

Expand All @@ -109,7 +109,7 @@ func (m *Manager) Set(id uint16, v interface{}) error {
return nil
}

// get gets the value associated with the `id`.
// Get gets the value associated with the `id`.
func (m *Manager) Get(id uint16) (interface{}, bool) {
m.mx.RLock()
lis, ok := m.values[id]
Expand All @@ -120,7 +120,7 @@ func (m *Manager) Get(id uint16) (interface{}, bool) {
return lis, ok
}

// doRange performs range over the manager contents. Loop stops when
// DoRange performs range over the manager contents. Loop stops when
// `next` returns false.
func (m *Manager) DoRange(next func(id uint16, v interface{}) bool) {
m.mx.RLock()
Expand Down

0 comments on commit 075cae8

Please sign in to comment.