Skip to content

Commit b9a966f

Browse files
committed
refactor: renamed some functions to avoid confusions
1 parent 6583c66 commit b9a966f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

safe_number.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ func (sn *SafeNumber) GetValue() int {
3737
return sn.value
3838
}
3939

40-
// GetValueAndIncrement returns the current value of the number and increments it by 1
41-
func (sn *SafeNumber) GetValueAndIncrement() int {
40+
// IncrementAndGetValue increments the number by 1 and returns the new value
41+
func (sn *SafeNumber) IncrementAndGetValue() int {
4242
sn.mu.Lock()
4343
defer sn.mu.Unlock()
4444
sn.value++
4545
return sn.value
4646
}
4747

48-
// GetValueAndDecrement returns the current value of the number and decrements it by 1
49-
func (sn *SafeNumber) GetValueAndDecrement() int {
48+
// DecrementAndGetValue decrements the number by 1 and returns the new value
49+
func (sn *SafeNumber) DecrementAndGetValue() int {
5050
sn.mu.Lock()
5151
defer sn.mu.Unlock()
5252
sn.value--
@@ -60,8 +60,8 @@ func (sn *SafeNumber) OperateValue(operation func(int) int) {
6060
sn.value = operation(sn.value)
6161
}
6262

63-
// GetAndOperateValue performs an operation on the value of the number and returns the result
64-
func (sn *SafeNumber) GetAndOperateValue(operation func(int) int) int {
63+
// OperateAndGetValue performs an operation on the value of the number and returns the result
64+
func (sn *SafeNumber) OperateAndGetValue(operation func(int) int) int {
6565
sn.mu.Lock()
6666
defer sn.mu.Unlock()
6767
sn.value = operation(sn.value)

0 commit comments

Comments
 (0)