Files
NetNewsWire/Modules/RSCore/Sources/RSCore/MainThreadBlockOperation.swift
T

26 lines
581 B
Swift

//
// MainThreadBlockOperation.swift
// RSCore
//
// Created by Brent Simmons on 1/16/20.
// Copyright © 2020 Ranchero Software, LLC. All rights reserved.
//
import Foundation
/// Run a block of code as an operation.
@MainActor public final class MainThreadBlockOperation: MainThreadOperation, @unchecked Sendable {
private let block: VoidBlock
public init(name: String? = nil, block: @escaping VoidBlock) {
self.block = block
super.init(name: name, completionBlock: nil)
}
override public func run() {
assert(Thread.isMainThread)
block()
didComplete()
}
}