[SERVER-29340] Add shortcut for incrementing atomic word by one Created: 23/May/17 Updated: 08/Jan/24 |
|
| Status: | Open |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | None |
| Fix Version/s: | features we're not sure of |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Charlie Swanson | Assignee: | Backlog - Service Architecture |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | features-not-sure-of | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Assigned Teams: |
Service Arch
|
| Participants: |
| Description |
|
We have an atomic fetchAndAdd(), but I'd imagine it's common to simply want to add one. Similarly for decrementing |
| Comments |
| Comment by Matt Diener (Inactive) [ 04/Apr/22 ] |
|
There are plenty of instances of `fetchAndAdd(1)` and `fetchAndAdd(-1)`. I think mira.carey@mongodb.com makes a convincing point and I'd personally like to see a name that addresses acm's concern. |
| Comment by Lauren Lewis (Inactive) [ 12/Nov/21 ] |
|
We haven’t heard back from you for some time, so I’m going to close this ticket. If this is still an issue for you, please provide additional information and we will reopen the ticket. |
| Comment by Mira Carey [ 26/May/17 ] |
|
One possible benefit might be better codegen (as the compiler would know the size of the increment and would have a wider available set of atomic ops available) |
| Comment by Andrew Morrow (Inactive) [ 24/May/17 ] |
|
We actually deliberately do not expose the pre and post increment operators for the underlying std::atomic, since there is a belief that using them is error-prone. Given that, I think this ticket is equivalent to requesting new fetchAndAddOne, addOneAndFetch, and the associated subtraction operations. It isn't clear to me that those methods read more clearly than fetchAndAdd(1). |