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
13 changes: 8 additions & 5 deletions Samples/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version:6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down Expand Up @@ -26,6 +26,9 @@ var targets: [PackageDescription.Target] = [
exclude: [
"dining-philosopher-fsm.graffle",
"dining-philosopher-fsm.svg",
],
swiftSettings: [
.swiftLanguageMode(.v5)
]
),

Expand All @@ -50,10 +53,10 @@ let package = Package(
name: "swift-distributed-actors-samples",
platforms: [
// we require the 'distributed actor' language and runtime feature:
.iOS(.v16),
.macOS(.v14),
.tvOS(.v16),
.watchOS(.v9),
.iOS(.v17),
.macOS(.v15),
.tvOS(.v17),
.watchOS(.v10),
],
products: [
// --- samples ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import Distributed
import Logging

import struct Foundation.Date

@testable import DistributedCluster

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

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

Expand Down
9 changes: 5 additions & 4 deletions Sources/DistributedCluster/Behaviors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,11 @@ extension _Behavior {
func receiveSignalAsync(
context: _ActorContext<Message>,
signal: _Signal,
handleSignal: @escaping @Sendable (
_ActorContext<Message>,
_Signal
) async throws -> _Behavior<Message>
handleSignal:
@escaping @Sendable (
_ActorContext<Message>,
_Signal
) async throws -> _Behavior<Message>
) -> _Behavior<Message> {
.setup { context in
receiveSignalAsync0(handleSignal, context: context, signal: signal)
Expand Down
2 changes: 1 addition & 1 deletion Sources/DistributedCluster/ClusterSystem+Clusterd.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Logging
import NIO

extension ClusterSystem {
public static func startClusterDaemon(configuredWith configureSettings: (inout ClusterSystemSettings) -> Void = { _ in () }) async -> ClusterDaemon {
public static func startClusterDaemon(configuredWith configureSettings: sending (inout ClusterSystemSettings) -> Void = { _ in () }) async -> ClusterDaemon {
let system = await ClusterSystem("clusterd") { settings in
settings.endpoint = ClusterDaemon.defaultEndpoint
configureSettings(&settings)
Expand Down
2 changes: 1 addition & 1 deletion Sources/DistributedCluster/ClusterSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public class ClusterSystem: DistributedActorSystem, @unchecked Sendable {
/// The name is useful for debugging cross system communication.
///
/// - Faults: when configuration closure performs very illegal action, e.g. reusing a serializer identifier
public convenience init(_ name: String, configuredWith configureSettings: (inout ClusterSystemSettings) -> Void = { _ in () }) async {
public convenience init(_ name: String, configuredWith configureSettings: sending (inout ClusterSystemSettings) -> Void = { _ in () }) async {
var settings = ClusterSystemSettings(name: name)
configureSettings(&settings)

Expand Down
Loading