Skip to content

Commit bd2e4c0

Browse files
committed
=build use 5.7 package definition; adjust build; define minimum platforms
1 parent 0716cf9 commit bd2e4c0

File tree

7 files changed

+12
-31
lines changed

7 files changed

+12
-31
lines changed

Package.swift

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

44
import class Foundation.ProcessInfo
@@ -228,6 +228,13 @@ let products: [PackageDescription.Product] = [
228228

229229
var package = Package(
230230
name: "swift-distributed-actors",
231+
platforms: [
232+
// we require the 'distributed actor' language and runtime feature:
233+
.iOS(.v16),
234+
.macOS(.v13),
235+
.tvOS(.v16),
236+
.watchOS(.v9),
237+
],
231238
products: products,
232239

233240
dependencies: dependencies,

Sources/DistributedActors/ActorTags.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ public struct ActorTags {
2222
// We still might re-think how we represent the storage.
2323
private var _storage: [String: Sendable & Codable] = [:] // FIXME: fix the key as AnyActorTagKey
2424

25-
init() {
25+
public init() {
2626
// empty tags
2727
}
2828

29-
init(tags: [any ActorTag]) {
29+
public init(tags: [any ActorTag]) {
3030
for tag in tags {
3131
self._storage[tag.id] = tag.value
3232
}

Sources/DistributedActors/Behaviors.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -557,14 +557,12 @@ open class _Interceptor<Message: Codable> {
557557
}
558558

559559
extension _Interceptor {
560-
@inlinable
561560
static func handleMessage(context: _ActorContext<Message>, behavior: _Behavior<Message>, interceptor: _Interceptor<Message>, message: Message) throws -> _Behavior<Message> {
562561
let next = try interceptor.interceptMessage(target: behavior, context: context, message: message)
563562

564563
return try _Interceptor.deduplicate(context: context, behavior: next, interceptor: interceptor)
565564
}
566565

567-
@inlinable
568566
static func deduplicate(context: _ActorContext<Message>, behavior: _Behavior<Message>, interceptor: _Interceptor<Message>) throws -> _Behavior<Message> {
569567
func deduplicate0(_ behavior: _Behavior<Message>) -> _Behavior<Message> {
570568
let hasDuplicatedIntercept = behavior.existsInStack { b in
@@ -601,7 +599,6 @@ extension _Behavior {
601599
///
602600
/// Note: The returned behavior MUST be `_Behavior.canonicalize`-ed in the vast majority of cases.
603601
// Implementation note: We don't do so here automatically in order to keep interpretations transparent and testable.
604-
@inlinable
605602
public func interpretMessage(context: _ActorContext<Message>, message: Message, file: StaticString = #file, line: UInt = #line) throws -> _Behavior<Message> {
606603
switch self.underlying {
607604
case .receiveMessage(let recv): return try recv(message)
@@ -648,7 +645,6 @@ extension _Behavior {
648645
}
649646

650647
/// Attempts interpreting signal using the current behavior, or returns `_Behavior.unhandled` if no `_Behavior.signalHandling` was found.
651-
@inlinable
652648
public func interpretSignal(context: _ActorContext<Message>, signal: _Signal) throws -> _Behavior<Message> {
653649
// This switch does not use a `default:` clause on purpose!
654650
// This is to enforce having to consider consider how a signal should be interpreted if a new behavior case is added.
@@ -723,7 +719,6 @@ extension _Behavior {
723719
}
724720

725721
/// Applies `interpretMessage` to an iterator of messages, while canonicalizing the behavior after every reduction.
726-
@inlinable
727722
internal func interpretMessages<Iterator: IteratorProtocol>(context: _ActorContext<Message>, messages: inout Iterator) throws -> _Behavior<Message> where Iterator.Element == Message {
728723
var currentBehavior: _Behavior<Message> = self
729724
while currentBehavior.isStillAlive {
@@ -740,7 +735,6 @@ extension _Behavior {
740735

741736
/// Validate if a _Behavior is legal to be used as "initial" behavior (when an Actor is spawned),
742737
/// since certain behaviors do not make sense as initial behavior.
743-
@inlinable
744738
internal func validateAsInitial() throws {
745739
switch self.underlying {
746740
case .same: throw IllegalBehaviorError.notAllowedAsInitial(self)
@@ -750,7 +744,6 @@ extension _Behavior {
750744
}
751745

752746
/// Same as `validateAsInitial`, however useful in chaining expressions as it returns itself when the validation has passed successfully.
753-
@inlinable
754747
internal func validatedAsInitial() throws -> _Behavior<Message> {
755748
try self.validateAsInitial()
756749
return self
@@ -837,7 +830,6 @@ extension _Behavior {
837830
///
838831
/// - Throws: `IllegalBehaviorError.tooDeeplyNestedBehavior` when a too deeply nested behavior is found,
839832
/// in order to avoid attempting to start an possibly infinitely deferred behavior.
840-
@inlinable
841833
internal func canonicalize(_ context: _ActorContext<Message>, next: _Behavior<Message>) throws -> _Behavior<Message> {
842834
guard self.isStillAlive else {
843835
return self // ignore, we're already dead and cannot become any other behavior
@@ -910,7 +902,6 @@ extension _Behavior {
910902
/// - Throws: `IllegalBehaviorError.tooDeeplyNestedBehavior` when a too deeply nested behavior is found,
911903
/// in order to avoid attempting to start an possibly infinitely deferred behavior.
912904
// TODO: make not recursive perhaps since could blow up on large chain?
913-
@inlinable
914905
internal func start(context: _ActorContext<Message>) throws -> _Behavior<Message> {
915906
let failAtDepth = context.system.settings.actor.maxBehaviorNestingDepth
916907

Sources/DistributedActors/StashBuffer.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ public final class _StashBuffer<Message: Codable> {
7272
/// requires the context to be passed in.
7373
/// - Throws: When any of the behavior reductions throws
7474
/// - Returns: The last behavior returned from processing the unstashed messages
75-
@inlinable
7675
public func unstashAll(context: _ActorContext<Message>, behavior: _Behavior<Message>) throws -> _Behavior<Message> {
7776
// TODO: can we make this honor the run length like `Mailbox` does?
7877
var iterator = self.buffer.iterator

Sources/DistributedActors/Supervision.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -412,39 +412,33 @@ internal class Supervisor<Message: Codable> {
412412
@usableFromInline
413413
typealias Directive = SupervisionDirective<Message>
414414

415-
@inlinable
416415
internal final func interpretSupervised(target: _Behavior<Message>, context: _ActorContext<Message>, message: Message) throws -> _Behavior<Message> {
417416
traceLog_Supervision("CALL WITH \(target) @@@@ [\(message)]:\(type(of: message))")
418417
return try self.interpretSupervised0(target: target, context: context, processingAction: .message(message))
419418
}
420419

421-
@inlinable
422420
internal final func interpretSupervised(target: _Behavior<Message>, context: _ActorContext<Message>, signal: _Signal) throws -> _Behavior<Message> {
423421
traceLog_Supervision("INTERCEPT SIGNAL APPLY: \(target) @@@@ \(signal)")
424422
return try self.interpretSupervised0(target: target, context: context, processingAction: .signal(signal))
425423
}
426424

427-
@inlinable
428425
internal final func interpretSupervised(target: _Behavior<Message>, context: _ActorContext<Message>, closure: ActorClosureCarry) throws -> _Behavior<Message> {
429426
traceLog_Supervision("CALLING CLOSURE: \(target)")
430427
return try self.interpretSupervised0(target: target, context: context, processingAction: .closure(closure))
431428
}
432429

433-
@inlinable
434430
internal final func interpretSupervised(target: _Behavior<Message>, context: _ActorContext<Message>, subMessage: SubMessageCarry) throws -> _Behavior<Message> {
435431
traceLog_Supervision("INTERPRETING SUB MESSAGE: \(target)")
436432
return try self.interpretSupervised0(target: target, context: context, processingAction: .subMessage(subMessage))
437433
}
438434

439-
@inlinable
440435
internal final func interpretSupervised(target: _Behavior<Message>, context: _ActorContext<Message>, closure: @escaping () throws -> _Behavior<Message>) throws -> _Behavior<Message> {
441436
traceLog_Supervision("CALLING CLOSURE: \(target)")
442437
return try self.interpretSupervised0(
443438
target: target, context: context, processingAction: .continuation(closure)
444439
)
445440
}
446441

447-
@inlinable
448442
internal final func startSupervised(target: _Behavior<Message>, context: _ActorContext<Message>) throws -> _Behavior<Message> {
449443
traceLog_Supervision("CALLING START")
450444
return try self.interpretSupervised0(
@@ -454,7 +448,6 @@ internal class Supervisor<Message: Codable> {
454448
}
455449

456450
/// Implements all directives, which supervisor implementations may yield to instruct how we should (if at all) restart an actor.
457-
@inlinable
458451
@inline(__always)
459452
final func interpretSupervised0(target: _Behavior<Message>, context: _ActorContext<Message>, processingAction: ProcessingAction<Message>) throws -> _Behavior<Message> {
460453
try self.interpretSupervised0(
@@ -463,7 +456,6 @@ internal class Supervisor<Message: Codable> {
463456
) // 1 since we already have "one failure"
464457
}
465458

466-
@inlinable
467459
@inline(__always)
468460
final func interpretSupervised0(
469461
target: _Behavior<Message>,

Sources/DistributedActors/_ActorShell.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ public final class _ActorShell<Message: Codable>: _ActorContext<Message>, Abstra
273273
///
274274
/// Warning: Mutates the cell's behavior.
275275
/// Returns: `true` if the actor remains alive, and `false` if it now is becoming `.stop`
276-
@inlinable
277276
func interpretMessage(message: Message) throws -> ActorRunResult {
278277
do {
279278
let next: _Behavior<Message> = try self.supervisor.interpretSupervised(target: self.behavior, context: self, message: message)
@@ -481,7 +480,7 @@ public final class _ActorShell<Message: Codable>: _ActorContext<Message>, Abstra
481480
/// MUST be preceded by an invocation of `restartPrepare`.
482481
/// The two steps MAY be performed in different point in time; reason being: backoff restarts,
483482
/// which need to suspend the actor, and NOT start it just yet, until the system message awakens it again.
484-
@inlinable public func _restartComplete(with behavior: _Behavior<Message>) throws -> _Behavior<Message> {
483+
public func _restartComplete(with behavior: _Behavior<Message>) throws -> _Behavior<Message> {
485484
try behavior.validateAsInitial()
486485
self.behavior = behavior
487486
try self.interpretStart()
@@ -492,13 +491,11 @@ public final class _ActorShell<Message: Codable>: _ActorContext<Message>, Abstra
492491
/// Always invoke `becomeNext` rather than assigning to `self.behavior` manually.
493492
///
494493
/// Returns: `true` if next behavior is .stop and appropriate actions will be taken
495-
@inlinable
496494
internal func becomeNext(behavior next: _Behavior<Message>) throws {
497495
// TODO: handling "unhandled" would be good here... though I think type wise this won't fly, since we care about signal too
498496
self.behavior = try self.behavior.canonicalize(self, next: next)
499497
}
500498

501-
@inlinable
502499
internal func interpretStart() throws {
503500
// start means we need to evaluate all `setup` blocks, since they need to be triggered eagerly
504501
traceLog_Cell("START with behavior: \(self.behavior)")
@@ -509,7 +506,6 @@ public final class _ActorShell<Message: Codable>: _ActorContext<Message>, Abstra
509506

510507
/// Interpret a `resume` with the passed in result, potentially waking up the actor from `suspended` state.
511508
/// Interpreting a resume NOT in suspended state is an error and should never happen.
512-
@inlinable
513509
internal func interpretResume(_ result: Result<Any, Error>) throws -> ActorRunResult {
514510
switch self.behavior.underlying {
515511
case .suspended(let previousBehavior, let handler):
@@ -796,7 +792,7 @@ extension _ActorShell {
796792
///
797793
/// Mutates actor cell behavior.
798794
/// May cause actor to terminate upon error or returning .stop etc from `.signalHandling` user code.
799-
@inlinable func interpretTerminatedSignal(who dead: ActorID, terminated: _Signals.Terminated) throws {
795+
func interpretTerminatedSignal(who dead: ActorID, terminated: _Signals.Terminated) throws {
800796
#if SACT_TRACE_ACTOR_SHELL
801797
self.log.info("Received terminated: \(dead)")
802798
#endif
@@ -852,7 +848,6 @@ extension _ActorShell {
852848

853849
/// Interpret a carried signal directly -- those are potentially delivered by plugins or custom transports.
854850
/// They MAY share semantics with `Signals.Terminated`, in which case they would be interpreted accordingly.
855-
@inlinable
856851
func interpretCarrySignal(_ signal: _Signal) throws {
857852
#if SACT_TRACE_ACTOR_SHELL
858853
self.log.info("Received carried signal: \(signal)")
@@ -867,13 +862,11 @@ extension _ActorShell {
867862
}
868863
}
869864

870-
@inlinable
871865
func interpretStop() throws {
872866
self.children.stopAll()
873867
try self.becomeNext(behavior: .stop(reason: .stopByParent))
874868
}
875869

876-
@inlinable
877870
func interpretChildTerminatedSignal(who terminatedRef: _AddressableActorRef, terminated: _Signals._ChildTerminated) throws {
878871
#if SACT_TRACE_ACTOR_SHELL
879872
self.log.info("Received \(terminated)")

Sources/DistributedActors/_BehaviorTimers.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ public final class _BehaviorTimers<Message: Codable> {
114114
/// Cancels timer associated with the given key.
115115
///
116116
/// - Parameter key: key of the timer to cancel
117-
@inlinable
118117
public func cancel(for key: TimerKey) {
119118
if let timer = self.installedTimers.removeValue(forKey: key) {
120119
if context.system.settings.logging.verboseTimers {

0 commit comments

Comments
 (0)