Skip to content

Commit

Permalink
7.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alemar11 authored Oct 28, 2024
1 parent a1d9ab6 commit dd1f065
Show file tree
Hide file tree
Showing 183 changed files with 315 additions and 40,396 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ concurrency:
jobs:
info:
name: Show macOS and Xcode versions
runs-on: macos-14
runs-on: macos-15
env:
DEVELOPER_DIR: /Applications/Xcode_15.3.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer
steps:
- name: stats
run: |
Expand All @@ -33,21 +33,21 @@ jobs:
brew info swiftlint
macOS:
name: Test macOS
runs-on: macos-14
runs-on: macos-15
env:
DEVELOPER_DIR: /Applications/Xcode_15.3.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer
steps:
- uses: actions/checkout@v4
- name: macOS
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -project "AdvancedOperation.xcodeproj" -scheme "AdvancedOperation" -destination "platform=macOS" clean test -quiet -resultBundlePath '~/Downloads/Report/report.xcresult'
iOS:
name: Test iOS
runs-on: macos-14
runs-on: macos-15
env:
DEVELOPER_DIR: /Applications/Xcode_15.3.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer
strategy:
matrix:
destination: ["OS=17.0,name=iPhone 15 Pro"]
destination: ["OS=18.0,name=iPhone 16 Pro"]
steps:
- uses: actions/checkout@v4
- name: iOS - ${{ matrix.destination }}
Expand All @@ -61,12 +61,12 @@ jobs:
path: ~/Downloads/Report
visionOS:
name: Test visionOS
runs-on: macos-14
runs-on: macos-15
env:
DEVELOPER_DIR: /Applications/Xcode_15.3.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer
strategy:
matrix:
destination: ["OS=1.0,name=Apple Vision Pro"]
destination: ["OS=2.0,name=Apple Vision Pro"]
steps:
- uses: actions/checkout@v4
- name: visionOS - ${{ matrix.destination }}
Expand All @@ -80,12 +80,12 @@ jobs:
path: ~/Downloads/Report
tvOS:
name: Test tvOS
runs-on: macos-14
runs-on: macos-15
env:
DEVELOPER_DIR: /Applications/Xcode_15.3.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer
strategy:
matrix:
destination: ["OS=17.0,name=Apple TV"]
destination: ["OS=18.0,name=Apple TV"]
steps:
- uses: actions/checkout@v4
- name: tvOS - ${{ matrix.destination }}
Expand All @@ -99,12 +99,12 @@ jobs:
path: ~/Downloads/Report
watchOS:
name: Test watchOS
runs-on: macos-14
runs-on: macos-15
env:
DEVELOPER_DIR: /Applications/Xcode_15.3.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer
strategy:
matrix:
destination: ["OS=10.0,name=Apple Watch Series 9 (45mm)"]
destination: ["OS=11.0,name=Apple Watch Series 10 (46mm)"]
steps:
- uses: actions/checkout@v4
- name: watchOS - ${{ matrix.destination }}
Expand All @@ -118,9 +118,9 @@ jobs:
path: ~/Downloads/Report
SPM:
name: Test SPM Integration
runs-on: macos-14
runs-on: macos-15
env:
DEVELOPER_DIR: /Applications/Xcode_15.3.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer
steps:
- uses: actions/checkout@v4
- name: SPM Test
Expand All @@ -129,7 +129,7 @@ jobs:
swift test
# lint:
# name: Swift Lint
# runs-on: macos-14
# runs-on: macos-15
# steps:
# - uses: actions/checkout@v4
# - name: Run SwiftLint
Expand Down
232 changes: 41 additions & 191 deletions AdvancedOperation.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
LastUpgradeVersion = "1610"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -29,7 +29,7 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<TestPlans>
<TestPlanReference
reference = "container:Tests/TestPlans/AdvancedOperation.xctestplan"
reference = "container:Support/AdvancedOperation.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

### 7.1.0

- Added `AsyncCancellableBlockOperation`.
- Swift 6 support
- Xcode 16 support

### 7.0.0

- SPM only
Expand Down
8 changes: 3 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// swift-tools-version:5.10
// swift-tools-version: 6.0

import PackageDescription
import Foundation

let buildingDocumentation = getenv("BUILDING_FOR_DOCUMENTATION_GENERATION") != nil

let swiftSettings: [SwiftSetting] = [
.enableExperimentalFeature("StrictConcurrency")
]
let swiftSettings: [SwiftSetting] = []

let package = Package(
name: "AdvancedOperation",
Expand All @@ -19,7 +17,7 @@ let package = Package(
.target(name: "AdvancedOperation", path: "Sources", swiftSettings: swiftSettings),
.testTarget(name: "AdvancedOperationTests", dependencies: ["AdvancedOperation"], swiftSettings: swiftSettings)
],
swiftLanguageVersions: [.v5]
swiftLanguageModes: [.v6]
)

// Only require the docc plugin when building documentation
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/AsynchronousOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public typealias AsyncOperation = AsynchronousOperation
/// An abstract thread safe subclass of `Operation` to support asynchronous operations.
///
/// Subclasses must override `main` to perform any work and, if they are asynchronous, call the `finish()` method to complete the execution.
open class AsynchronousOperation: Operation, ProgressReporting {
open class AsynchronousOperation: Operation, ProgressReporting, @unchecked Sendable {
// MARK: - Public Properties

/// The `progress` property represents a total progress of the operation during its execution.
Expand Down
19 changes: 13 additions & 6 deletions Sources/Operations/AsynchronousBlockOperation.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
// AdvancedOperation

import Foundation
import os.lock

public typealias AsyncBlockOperation = AsynchronousBlockOperation

/// A sublcass of `AsynchronousOperation` to execute a closure.
public final class AsynchronousBlockOperation: AsynchronousOperation {
/// A closure type that takes a closure as its parameter.
public typealias Block = (@Sendable @escaping () -> Void) -> Void

/// - Note: If the operation gets cancelled before being executed, the block won't be called.
///
/// This operation let you run a block until *complete* is called.
/// ```
/// let operation = AsyncCancellableBlockOperation { complete in
/// // work ...
/// complete()
/// }
public final class AsynchronousBlockOperation: AsynchronousOperation, @unchecked Sendable {
// MARK: - Private Properties

private var block: Block
private let block: (@Sendable @escaping () -> Void) -> Void

// MARK: - Initializers

Expand All @@ -20,7 +26,8 @@ public final class AsynchronousBlockOperation: AsynchronousOperation {
/// - Parameters:
/// - block: The closure to run when the operation executes; the parameter passed to the block **MUST** be invoked by your code,
/// or else the `AsynchronousBlockOperation` will never finish executing.
public init(block: @escaping Block) {
public init(block: @Sendable @escaping (@Sendable @escaping () -> Void) -> Void) {
// block is @Sendable because of https://github.com/swiftlang/swift/issues/75453#issuecomment-2374682664
self.block = block
super.init()
self.name = "\(type(of: self))"
Expand Down
51 changes: 51 additions & 0 deletions Sources/Operations/AsynchronousCancellableBlockOperation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// AdvancedOperation

public typealias AsyncCancellableBlockOperation = AsynchronousCancellableBlockOperation

/// A sublcass of `AsynchronousOperation` to execute a cancellable closure.
/// - Note: If the operation gets cancelled before being executed, the block won't be called.
///
/// This operation let you run a block until *complete* is called; its cancelled state is exposed during the whole execution.
/// ```
/// let operation = AsyncCancellableBlockOperation { isCancelled, complete in
/// // work ...
/// if isCancelled() {
/// complete()
/// return
/// }
/// // work ...
/// complete()
/// }
public final class AsynchronousCancellableBlockOperation: AsynchronousOperation, @unchecked Sendable {
// MARK: - Private Properties

private var block: (@escaping @Sendable () -> Bool, @escaping @Sendable () -> Void) -> Void

// MARK: - Initializers

/// The designated initializer.
///
/// - Parameters:
/// - block: The closure to run when the operation executes; the parameter passed to the block **MUST** be invoked by your code,
/// or else the `AsynchronousBlockOperation` will never finish executing.
public init(block: @Sendable @escaping (@escaping @Sendable () -> Bool, @escaping @Sendable () -> Void) -> Void) {
self.block = block
super.init()
self.name = "\(type(of: self))"
}

// MARK: - Overrides

public final override func main() {
guard !isCancelled else {
self.finish()
return
}

block ({
self.isCancelled
}) {
self.finish()
}
}
}
2 changes: 1 addition & 1 deletion Sources/Operations/FailableAsyncOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import os.lock
public typealias FailableAsyncOperation = FailableAsynchronousOperation

/// An `AsynchronousOperation` that can finish with an error conforming to `OperationError`.
open class FailableAsynchronousOperation<Failure: Error>: AsynchronousOperation {
open class FailableAsynchronousOperation<Failure: Error>: AsynchronousOperation, @unchecked Sendable {
private var _error = OSAllocatedUnfairLock<Failure?>(initialState: nil)

/// Failure error.
Expand Down
5 changes: 2 additions & 3 deletions Sources/Operations/GroupOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Foundation

/// An `AsynchronousOperation` subclass which enables a finite grouping of other operations.
/// Use a `GroupOperation` to associate related operations together, thereby creating higher levels of abstractions.
open class GroupOperation: AsynchronousOperation {
open class GroupOperation: AsynchronousOperation, @unchecked Sendable {
// MARK: - Public Properties

/// The maximum number of queued operations that can execute at the same time inside the `GroupOperation`.
Expand Down Expand Up @@ -57,8 +57,7 @@ open class GroupOperation: AsynchronousOperation {
}

deinit {
// An observation token may cause crashes during its deinit phase if its observed object (an Operation)
// has been already deallocated
// An observation token may cause crashes during its deinit phase if its observed object (an Operation) has been already deallocated.
// To fix this issue:
// 1. we store all the operations in a private array (the internal OperationQueue will release them once finished,
// that's why we need to do so)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Operations/ResultOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import os.lock
/// An `AsynchronousOperation` that produces a `result` once finished.
///
/// If a `ResultOperation` gets cancelled before being executed, no result will be produced by default.
open class ResultOperation<Success, Failure>: AsynchronousOperation where Success: Sendable, Failure: Error {
open class ResultOperation<Success, Failure>: AsynchronousOperation, @unchecked Sendable where Success: Sendable, Failure: Error {
/// Block executed after the operation is finished providing the final result (if any).
/// - Note: `onFinish` and `completionBlock` call order is not guaranteed in any way.
public var onFinish: ((Result<Success, Failure>?) -> Void)?
Expand Down
File renamed without changes.
22 changes: 0 additions & 22 deletions Support/Info-Tests.plist

This file was deleted.

28 changes: 0 additions & 28 deletions Support/Info-tvOS.plist

This file was deleted.

24 changes: 0 additions & 24 deletions Support/Info.plist

This file was deleted.

Loading

0 comments on commit dd1f065

Please sign in to comment.