Skip to content

Commit

Permalink
concurrency fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tgymnich committed Jun 26, 2024
1 parent ab2c29b commit 505d75b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ let package = Package(
targets: [
.target(name: "BigInt", path: "Sources"),
.testTarget(name: "BigIntTests", dependencies: ["BigInt"], path: "Tests")
],
swiftLanguageVersions: [.v5]
]
)
4 changes: 2 additions & 2 deletions Sources/BigInt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
/// BigInt(255).magnitude.isPrime() // Returns false
/// ```
///
public struct BigInt: SignedInteger {
public enum Sign {
public struct BigInt: SignedInteger, Sendable {
public enum Sign: Sendable {
case plus
case minus
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/BigUInt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
///
/// This particular big integer type uses base-2^64 digits to represent integers; you can think of it as a wrapper
/// around `Array<UInt64>`. (In fact, `BigUInt` only uses an array if there are more than two digits.)
public struct BigUInt: UnsignedInteger {
public struct BigUInt: UnsignedInteger, Sendable {
/// The type representing a digit in `BigUInt`'s underlying number system.
public typealias Word = UInt

Expand Down
2 changes: 1 addition & 1 deletion Sources/Multiplication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ extension BigUInt {
}

/// Multiplication switches to an asymptotically better recursive algorithm when arguments have more words than this limit.
public static var directMultiplicationLimit: Int = 1024
public static let directMultiplicationLimit: Int = 1024

/// Multiply `a` by `b` and return the result.
///
Expand Down
10 changes: 5 additions & 5 deletions Tests/BigIntTests/BigUIntTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -832,11 +832,11 @@ class BigUIntTests: XCTestCase {

test()
// Disable brute force multiplication.
let limit = BigUInt.directMultiplicationLimit
BigUInt.directMultiplicationLimit = 0
defer { BigUInt.directMultiplicationLimit = limit }

test()
// let limit = BigUInt.directMultiplicationLimit
// BigUInt.directMultiplicationLimit = 0
// defer { BigUInt.directMultiplicationLimit = limit }
//
// test()
}

func testDivision() {
Expand Down

0 comments on commit 505d75b

Please sign in to comment.