Skip to content
Open
Show file tree
Hide file tree
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
15 changes: 5 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,15 @@ jobs:
name: "Sample dining philosophers"
matrix_string: '${{ needs.construct-dining-philosophers-matrix.outputs.dining-philosophers-matrix }}'

cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
with:
linux_5_9_enabled: false
linux_5_10_enabled: false

macos-tests:
name: macOS tests
uses: apple/swift-nio/.github/workflows/macos_tests.yml@main
with:
runner_pool: nightly
build_scheme: swift-distributed-actors-Package

static-sdk:
name: Static SDK
uses: apple/swift-nio/.github/workflows/static_sdk.yml@main
# Removed for now as static sdk builds are not working
# https://github.com/apple/swift-distributed-actors/issues/1229
# static-sdk:
# name: Static SDK
# uses: apple/swift-nio/.github/workflows/static_sdk.yml@main
16 changes: 6 additions & 10 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
# https://github.com/apple/swift-distributed-actors/issues/1225
api_breakage_check_enabled: false
license_header_check_project_name: "Swift Distributed Actors"

Expand Down Expand Up @@ -78,20 +79,15 @@ jobs:
name: "Sample dining philosophers"
matrix_string: '${{ needs.construct-dining-philosophers-matrix.outputs.dining-philosophers-matrix }}'

cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
with:
linux_5_9_enabled: false
linux_5_10_enabled: false

macos-tests:
name: macOS tests
uses: apple/swift-nio/.github/workflows/macos_tests.yml@main
with:
runner_pool: general
build_scheme: swift-distributed-actors-Package

static-sdk:
name: Static SDK
uses: apple/swift-nio/.github/workflows/static_sdk.yml@main
# Removed for now as static sdk builds are not working
# https://github.com/apple/swift-distributed-actors/issues/1229
# static-sdk:
# name: Static SDK
# uses: apple/swift-nio/.github/workflows/static_sdk.yml@main
4 changes: 2 additions & 2 deletions Sources/DistributedActorsConcurrencyHelpers/lock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
#if canImport(Darwin)
import Darwin
#else
#elseif canImport(Glibc)
import Glibc
#endif

Expand Down
4 changes: 2 additions & 2 deletions Sources/DistributedCluster/Collections/Heap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

// Based on https://raw.githubusercontent.com/apple/swift-nio/bf2598d19359e43b4cfaffaff250986ebe677721/Sources/NIO/Heap.swift

#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
#if canImport(Darwin)
import Darwin
#else
#elseif canImport(Glibc)
import Glibc
#endif

Expand Down
8 changes: 4 additions & 4 deletions Sources/DistributedCluster/Concurrency/_Condition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

import NIO

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
#if canImport(Darwin)
import Darwin
#else
#elseif canImport(Glibc)
import Glibc
#endif

Expand Down Expand Up @@ -58,15 +58,15 @@ public final class _Condition {

@inlinable
public func wait(_ mutex: _Mutex, atMost duration: Duration) -> Bool {
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
#if canImport(Darwin)
let time = TimeSpec.from(duration: duration)
#else
var now = timespec()
clock_gettime(CLOCK_REALTIME, &now)
let time = now + TimeSpec.from(duration: duration)
#endif
let error = withUnsafePointer(to: time) { p -> Int32 in
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
#if canImport(Darwin)
return pthread_cond_timedwait_relative_np(&condition, &mutex.mutex, p)
#else
return pthread_cond_timedwait(&condition, &mutex.mutex, p)
Expand Down
4 changes: 2 additions & 2 deletions Sources/DistributedCluster/Concurrency/_Thread.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import Atomics
import DistributedActorsConcurrencyHelpers
import NIO

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
#if canImport(Darwin)
import Darwin
#else
#elseif canImport(Glibc)
import Glibc
#endif

Expand Down
4 changes: 2 additions & 2 deletions Sources/DistributedCluster/Concurrency/locks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
#if canImport(Darwin)
import Darwin
#else
#elseif canImport(Glibc)
import Glibc
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// ==== ----------------------------------------------------------------------------------------------------------------
// MARK: Instrumentation

#if os(macOS) || os(tvOS) || os(iOS) || os(watchOS)
#if canImport(Darwin)
import Foundation
import os.log
import os.signpost
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(tvOS) || os(iOS) || os(watchOS)
#if canImport(Darwin)
/// Provider of Instrumentation instances which use `os_signpost`.
internal struct OSSignpostInstrumentationProvider: ClusterSystemInstrumentationProvider {
init() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(tvOS) || os(iOS) || os(watchOS)
#if canImport(Darwin)
import Foundation
import os.log
import os.signpost
Expand Down
11 changes: 5 additions & 6 deletions Sources/DistributedCluster/Pattern/WorkerPool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public distributed actor WorkerPool<Worker: DistributedWorker>: DistributedWorke
level: self.logLevel,
"Incoming work, selecting worker",
metadata: [
"workers/count": "\(self.size())",
"workers/count": "\(self.size)",
"worker/item": "\(work)",
]
)
Expand All @@ -132,14 +132,13 @@ public distributed actor WorkerPool<Worker: DistributedWorker>: DistributedWorke
"Selected worker, submitting [\(work)] to [\(worker)]",
metadata: [
"worker": "\(worker.id)",
"workers/count": "\(self.size())",
"workers/count": "\(self.size)",
]
)
return try await worker.submit(work: work)
}

// FIXME: there is an issue in latest Swift (6.2 nightlies) with Cxx interop, change back to computed properties when fixed.
internal distributed func size() -> Int {
internal distributed var size: Int {
self.workers.count
}

Expand Down Expand Up @@ -199,11 +198,11 @@ public distributed actor WorkerPool<Worker: DistributedWorker>: DistributedWorke
case .random:
return self.workers.shuffled().first
case .simpleRoundRobin:
if self.roundRobinPos >= self.size() {
if self.roundRobinPos >= self.size {
self.roundRobinPos = 0 // loop around from zero
}
let selected = self.workers[self.roundRobinPos]
self.roundRobinPos = self.workers.index(after: self.roundRobinPos) % self.size()
self.roundRobinPos = self.workers.index(after: self.roundRobinPos) % self.size
return selected
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/DistributedCluster/TimeSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

import NIO

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
#if canImport(Darwin)
import Darwin
#else
#elseif canImport(Glibc)
import Glibc
#endif

Expand Down
6 changes: 3 additions & 3 deletions Tests/DistributedClusterTests/Pattern/WorkerPoolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class WorkerPoolTests: SingleClusterSystemXCTestCase {
let finished = expectation(description: "all workers available")
Task {
while true {
if try await workers.size() == workerProbes.count {
if try await workers.size == workerProbes.count {
break
}
try await Task.sleep(nanoseconds: 100_000_000)
Expand Down Expand Up @@ -93,7 +93,7 @@ final class WorkerPoolTests: SingleClusterSystemXCTestCase {
let finished = expectation(description: "all workers available")
Task {
while true {
if try await workers.size() == workerProbes.count {
if try await workers.size == workerProbes.count {
break
}
try await Task.sleep(nanoseconds: 100_000_000)
Expand Down Expand Up @@ -276,7 +276,7 @@ final class WorkerPoolTests: SingleClusterSystemXCTestCase {
let finished = expectation(description: "all workers available")
Task {
while true {
if try await workers.size() == workerProbes.count {
if try await workers.size == workerProbes.count {
break
}
try await Task.sleep(nanoseconds: 100_000_000)
Expand Down
4 changes: 2 additions & 2 deletions Tests/DistributedClusterTests/SupervisionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import XCTest

@testable import DistributedCluster

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
#if canImport(Darwin)
import Darwin
#else
#elseif canImport(Glibc)
import Glibc
#endif

Expand Down
Loading