Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stdlib] Make atomics sharable #3943

Open
wants to merge 1 commit into
base: nightly
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions stdlib/src/os/atomic.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct Atomic[type: DType, *, scope: StringLiteral = ""]:
self.value = value

@always_inline
fn load(mut self) -> Scalar[type]:
fn load(self) -> Scalar[type]:
"""Loads the current value from the atomic.

Returns:
Expand Down Expand Up @@ -139,7 +139,7 @@ struct Atomic[type: DType, *, scope: StringLiteral = ""]:
)

@always_inline
fn fetch_add(mut self, rhs: Scalar[type]) -> Scalar[type]:
fn fetch_add(self, rhs: Scalar[type]) -> Scalar[type]:
"""Performs atomic in-place add.

Atomically replaces the current value with the result of arithmetic
Expand All @@ -158,7 +158,7 @@ struct Atomic[type: DType, *, scope: StringLiteral = ""]:
return Self._fetch_add(value_addr, rhs)

@always_inline
fn __iadd__(mut self, rhs: Scalar[type]):
fn __iadd__(self, rhs: Scalar[type]):
"""Performs atomic in-place add.

Atomically replaces the current value with the result of arithmetic
Expand All @@ -173,7 +173,7 @@ struct Atomic[type: DType, *, scope: StringLiteral = ""]:
_ = self.fetch_add(rhs)

@always_inline
fn fetch_sub(mut self, rhs: Scalar[type]) -> Scalar[type]:
fn fetch_sub(self, rhs: Scalar[type]) -> Scalar[type]:
"""Performs atomic in-place sub.

Atomically replaces the current value with the result of arithmetic
Expand All @@ -197,7 +197,7 @@ struct Atomic[type: DType, *, scope: StringLiteral = ""]:
](value_addr.address, rhs.value)

@always_inline
fn __isub__(mut self, rhs: Scalar[type]):
fn __isub__(self, rhs: Scalar[type]):
"""Performs atomic in-place sub.

Atomically replaces the current value with the result of arithmetic
Expand All @@ -213,7 +213,7 @@ struct Atomic[type: DType, *, scope: StringLiteral = ""]:

@always_inline
fn compare_exchange_weak(
mut self, mut expected: Scalar[type], desired: Scalar[type]
self, mut expected: Scalar[type], desired: Scalar[type]
) -> Bool:
"""Atomically compares the self value with that of the expected value.
If the values are equal, then the self value is replaced with the
Expand Down Expand Up @@ -271,7 +271,7 @@ struct Atomic[type: DType, *, scope: StringLiteral = ""]:
_max_impl[scope=scope](ptr, rhs)

@always_inline
fn max(mut self, rhs: Scalar[type]):
fn max(self, rhs: Scalar[type]):
"""Performs atomic in-place max.

Atomically replaces the current value with the result of max of the
Expand Down Expand Up @@ -311,7 +311,7 @@ struct Atomic[type: DType, *, scope: StringLiteral = ""]:
_min_impl[scope=scope](ptr, rhs)

@always_inline
fn min(mut self, rhs: Scalar[type]):
fn min(self, rhs: Scalar[type]):
"""Performs atomic in-place min.

Atomically replaces the current value with the result of min of the
Expand Down
Loading