Skip to content

chore: refactor to use modern atomic types#3277

Merged
dnwe merged 3 commits intoIBM:mainfrom
Sahil-4555:refactor-atomic-types
Sep 2, 2025
Merged

chore: refactor to use modern atomic types#3277
dnwe merged 3 commits intoIBM:mainfrom
Sahil-4555:refactor-atomic-types

Conversation

@Sahil-4555
Copy link
Copy Markdown
Contributor

@Sahil-4555 Sahil-4555 commented Sep 2, 2025

What type of PR is this?

Other

What does this PR do? Why is it needed?
This PR updates our atomic operations to use Go 1.19's newer typed atomic approach instead of the old function-based method. We're changing fields like int64 to atomic.Int64 so we can write cleaner code like child.retries.Add(1) instead of atomic.AddInt32(&child.retries, 1). This removes the need for pointer handling and gives us better compile-time safety when multiple threads access the same variables in operations.

Which issues(s) does this PR fix?
The function-based atomics allowed accidental non-atomic access to shared variables, causing race conditions in concurrent operations. The verbose atomic.AddInt32(&child.retries, 1) syntax was harder to maintain. Typed atomics enforce atomic-only access at compile time and use cleaner method calls, preventing threading bugs.

@Sahil-4555 Sahil-4555 force-pushed the refactor-atomic-types branch from 198bd93 to a36a9b8 Compare September 2, 2025 05:59
Copy link
Copy Markdown
Collaborator

@puellanivis puellanivis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few suggestions.

@Sahil-4555 Sahil-4555 force-pushed the refactor-atomic-types branch from 659dc7a to 32abe92 Compare September 2, 2025 14:49
Signed-off-by: Sahil-4555 <[email protected]>
@Sahil-4555 Sahil-4555 force-pushed the refactor-atomic-types branch from aaab49a to 2fb0acd Compare September 2, 2025 14:59
@dnwe dnwe added the chore label Sep 2, 2025
@dnwe dnwe changed the title refactor to use atomic types chore: refactor to use modern atomic types Sep 2, 2025
Copy link
Copy Markdown
Collaborator

@puellanivis puellanivis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t see anything to comment on. 👍

Copy link
Copy Markdown
Collaborator

@dnwe dnwe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! A good piece of housekeeping

@dnwe dnwe merged commit 72c7448 into IBM:main Sep 2, 2025
17 checks passed
@Sahil-4555 Sahil-4555 deleted the refactor-atomic-types branch November 27, 2025 05:21
dnwe pushed a commit that referenced this pull request Dec 17, 2025
This completes the change in #3277 and rolls out all atomics usage to
using the types, rather than the bare functions.

This already found a few usages that had inconsistently used atomic
functions on some values.

---------

Signed-off-by: Cassondra Foesch <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants