On Wed, Feb 27, 2019 at 12:46 PM Serhat Şevki Dinçer wrote:
>
> I would like to update a counter up to a certain limit atomically, without
> using a channel or mutex. What do you think of the following (equivalent)
> functions for sync/atomic?
>
> func CompareAndInc(*addr, Max) bool {
>
> if *
Hi,
I would like to update a counter up to a certain limit atomically, without
using a channel or mutex. What do you think of the following (equivalent)
functions for sync/atomic?
func CompareAndInc(*addr, Max) bool {
if *addr < Max {
*addr++
return true
}
return false
}
func Co