mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-28 00:04:25 +00:00
26 lines
581 B
Swift
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()
|
|
}
|
|
}
|