Open karthik2804 opened 6 months ago
That's a good quetsion. Changing the delta and return value type to i64
indeeds give more flexibility and allows the increment
operation to also behave as a decrement
if the delta
is a negative integer.
The reason behind choosing an u64
is that common usage scenarios like counters, timestamps are all positive and this ensures that the operation will not accidentally decreases the value.
Do you have an use case for decrementing?
Do you think adding a decrement
function would be sufficient for your use case?
Currently, the signature of the atomic increment is
I would like to understand the reasoning behind the
delta
argument and the returnu64
types. This would not support cases where atomic decrement is desired. Would it be better for the types to bei64
to allow for flexibility?