Skip to content

Commit 61defc9

Browse files
authored
remove swift-atomics (#203)
* remove swift-atomics * fix test
1 parent 80a45d5 commit 61defc9

File tree

11 files changed

+22
-68
lines changed

11 files changed

+22
-68
lines changed

Blockchain/Package.resolved

Lines changed: 1 addition & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Blockchain/Sources/Blockchain/Validator/ServiceBase2.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import Atomics
21
import Foundation
32
import TracingUtils
43
import Utils

JAMTests/Package.resolved

Lines changed: 2 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PolkaVM/Package.resolved

Lines changed: 2 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Utils/Package.resolved

Lines changed: 2 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Utils/Package.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ let package = Package(
2121
.package(url: "https://github.com/tesseract-one/Blake2.swift.git", from: "0.2.0"),
2222
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "4.0.0"),
2323
.package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"),
24-
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.2.0"),
2524
.package(url: "https://github.com/apple/swift-numerics.git", branch: "main"),
2625
],
2726
targets: [
@@ -34,7 +33,6 @@ let package = Package(
3433
"TracingUtils",
3534
.product(name: "Blake2", package: "Blake2.swift"),
3635
.product(name: "Crypto", package: "swift-crypto"),
37-
.product(name: "Atomics", package: "swift-atomics"),
3836
.product(name: "Numerics", package: "swift-numerics"),
3937
"bls",
4038
"bandersnatch_vrfs",

Utils/Sources/Utils/EventBus/EventBus.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import Atomics
21
import Foundation
32
import TracingUtils
43

Utils/Sources/Utils/Lazy.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import Atomics
1+
import Synchronization
22

33
/// A thread-safe lazy value.
44
/// Note: The initializer could be called multiple times.
5-
public final class Lazy<T: AtomicReference> {
6-
private let ref = ManagedAtomicLazyReference<T>()
5+
public final class Lazy<T: AnyObject> {
6+
private let ref = AtomicLazyReference<T>()
77
private let initFn: @Sendable () -> T
88

99
public init(_ initFn: @Sendable @escaping () -> T) {
@@ -12,7 +12,7 @@ public final class Lazy<T: AtomicReference> {
1212

1313
public var value: T {
1414
guard let value = ref.load() else {
15-
return ref.storeIfNilThenLoad(initFn())
15+
return ref.storeIfNil(initFn())
1616
}
1717
return value
1818
}

Utils/Sources/Utils/Ref.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import Atomics
2-
3-
open class Ref<T: Sendable>: @unchecked Sendable, AtomicReference, CustomStringConvertible {
1+
open class Ref<T: Sendable>: @unchecked Sendable, CustomStringConvertible {
42
public let value: T
53

64
public required init(_ value: T) {

Utils/Sources/Utils/UniqueId.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import Atomics
1+
import Synchronization
22
import TracingUtils
33

44
public struct UniqueId: Sendable {
5-
private static let idGenerator: ManagedAtomic<Int> = ManagedAtomic(0)
5+
private static let idGenerator: Atomic<Int> = .init(0)
66

77
public let id: Int
88
public let name: String
99

1010
public init(_ name: String = "") {
11-
id = UniqueId.idGenerator.loadThenWrappingIncrement(ordering: .relaxed)
11+
(_, id) = UniqueId.idGenerator.wrappingAdd(1, ordering: .relaxed)
1212
self.name = name
1313
}
1414

0 commit comments

Comments
 (0)