Skip to content

Commit

Permalink
update std::sync::atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Aug 30, 2023
1 parent d8148cb commit 69e2043
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions src/standard-library/std-sync-atomic.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,87 @@ fn store_uinptr(mut &addr: uintptr, val: uintptr, order: MemoryOrder)
```
Atomically stores val into addr.

## Structures

```jule
struct AtomicInt
```
Type alias for private wrapper structure for int type.

**Methods:**

`static fn new(n: int): AtomicInt` \
Returns new atomic instance for type with initializer value.

`fn swap(mut self, new: int, order: MemoryOrder): (old: int)`\
Atomically stores new value and returns the previous value.

`fn compare_swap(mut self, old: int, new: int, order: MemoryOrder): (swapped: bool)`\
Executes the compare-and-swap operation.

`fn add(mut self, delta: int, order: MemoryOrder): (old: int)`\
Atomically adds delta to value and returns the previous value.

`fn load(self, order: MemoryOrder): int`\
Atomically reads and returns value.

`fn store(mut self, val: int, order: MemoryOrder)`\
Atomically assigns to value.

---

```jule
struct AtomicUint
```
Type alias for private wrapper structure for uint type.

**Methods:**

`static fn new(n: uint): AtomicUint` \
Returns new atomic instance for type with initializer value.

`fn swap(mut self, new: uint, order: MemoryOrder): (old: uint)`\
Atomically stores new value and returns the previous value.

`fn compare_swap(mut self, old: uint, new: uint, order: MemoryOrder): (swapped: bool)`\
Executes the compare-and-swap operation.

`fn add(mut self, delta: uint, order: MemoryOrder): (old: uint)`\
Atomically adds delta to value and returns the previous value.

`fn load(self, order: MemoryOrder): uint`\
Atomically reads and returns value.

`fn store(mut self, val: uint, order: MemoryOrder)`\
Atomically assigns to value.

---

```jule
struct AtomicUintptr
```
Type alias for private wrapper structure for uintptr type.

**Methods:**

`static fn new(n: uintptr): AtomicUintptr` \
Returns new atomic instance for type with initializer value.

`fn swap(mut self, new: uintptr, order: MemoryOrder): (old: uintptr)`\
Atomically stores new value and returns the previous value.

`fn compare_swap(mut self, old: uintptr, new: uintptr, order: MemoryOrder): (swapped: bool)`\
Executes the compare-and-swap operation.

`fn add(mut self, delta: uintptr, order: MemoryOrder): (old: uintptr)`\
Atomically adds delta to value and returns the previous value.

`fn load(self, order: MemoryOrder): uintptr`\
Atomically reads and returns value.

`fn store(mut self, val: uintptr, order: MemoryOrder)`\
Atomically assigns to value.

## Enums
`enum MemoryOrder`

Expand Down

0 comments on commit 69e2043

Please sign in to comment.