Skip to content

Commit 44cff54

Browse files
authored
Mark configuration setting closure as sending (#1224)
1 parent 7d8a599 commit 44cff54

File tree

5 files changed

+18
-23
lines changed

5 files changed

+18
-23
lines changed

Samples/Package.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.9
1+
// swift-tools-version:6.0
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
@@ -26,6 +26,9 @@ var targets: [PackageDescription.Target] = [
2626
exclude: [
2727
"dining-philosopher-fsm.graffle",
2828
"dining-philosopher-fsm.svg",
29+
],
30+
swiftSettings: [
31+
.swiftLanguageMode(.v5)
2932
]
3033
),
3134

@@ -50,10 +53,10 @@ let package = Package(
5053
name: "swift-distributed-actors-samples",
5154
platforms: [
5255
// we require the 'distributed actor' language and runtime feature:
53-
.iOS(.v16),
54-
.macOS(.v14),
55-
.tvOS(.v16),
56-
.watchOS(.v9),
56+
.iOS(.v17),
57+
.macOS(.v15),
58+
.tvOS(.v17),
59+
.watchOS(.v10),
5760
],
5861
products: [
5962
// --- samples ---

Samples/Sources/SampleDiningPhilosophers/SamplePrettyLogHandler.swift

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import Distributed
1616
import Logging
1717

18+
import struct Foundation.Date
19+
1820
@testable import DistributedCluster
1921

2022
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
@@ -129,18 +131,7 @@ struct SamplePrettyLogHandler: LogHandler {
129131
}
130132

131133
private func timestamp() -> String {
132-
var buffer = [Int8](repeating: 0, count: 255)
133-
var timestamp = time(nil)
134-
let localTime = localtime(&timestamp)
135-
// This format is pleasant to read in local sample apps:
136-
strftime(&buffer, buffer.count, "%H:%M:%S", localTime)
137-
// The usual full format is:
138-
// strftime(&buffer, buffer.count, "%Y-%m-%dT%H:%M:%S%z", localTime)
139-
return buffer.withUnsafeBufferPointer {
140-
$0.withMemoryRebound(to: CChar.self) {
141-
String(cString: $0.baseAddress!)
142-
}
143-
}
134+
Date.now.formatted(date: .omitted, time: .standard)
144135
}
145136
}
146137

Sources/DistributedCluster/Behaviors.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,11 @@ extension _Behavior {
131131
func receiveSignalAsync(
132132
context: _ActorContext<Message>,
133133
signal: _Signal,
134-
handleSignal: @escaping @Sendable (
135-
_ActorContext<Message>,
136-
_Signal
137-
) async throws -> _Behavior<Message>
134+
handleSignal:
135+
@escaping @Sendable (
136+
_ActorContext<Message>,
137+
_Signal
138+
) async throws -> _Behavior<Message>
138139
) -> _Behavior<Message> {
139140
.setup { context in
140141
receiveSignalAsync0(handleSignal, context: context, signal: signal)

Sources/DistributedCluster/ClusterSystem+Clusterd.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import Logging
2323
import NIO
2424

2525
extension ClusterSystem {
26-
public static func startClusterDaemon(configuredWith configureSettings: (inout ClusterSystemSettings) -> Void = { _ in () }) async -> ClusterDaemon {
26+
public static func startClusterDaemon(configuredWith configureSettings: sending (inout ClusterSystemSettings) -> Void = { _ in () }) async -> ClusterDaemon {
2727
let system = await ClusterSystem("clusterd") { settings in
2828
settings.endpoint = ClusterDaemon.defaultEndpoint
2929
configureSettings(&settings)

Sources/DistributedCluster/ClusterSystem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public class ClusterSystem: DistributedActorSystem, @unchecked Sendable {
209209
/// The name is useful for debugging cross system communication.
210210
///
211211
/// - Faults: when configuration closure performs very illegal action, e.g. reusing a serializer identifier
212-
public convenience init(_ name: String, configuredWith configureSettings: (inout ClusterSystemSettings) -> Void = { _ in () }) async {
212+
public convenience init(_ name: String, configuredWith configureSettings: sending (inout ClusterSystemSettings) -> Void = { _ in () }) async {
213213
var settings = ClusterSystemSettings(name: name)
214214
configureSettings(&settings)
215215

0 commit comments

Comments
 (0)