Skip to content

Commit ccf05d8

Browse files
authored
update swift-concurrency supports (#120)
1 parent 9a33ab0 commit ccf05d8

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

Sources/Components/Tools/NamedDisplayCellNodeBase.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
import AsyncDisplayKit
2323

24-
fileprivate let queue = DispatchQueue.global()
25-
2624
/// An object from Abstract base class
2725
///
2826
/// This object sets name of object for accessibilityIdentifier
@@ -32,16 +30,17 @@ fileprivate let queue = DispatchQueue.global()
3230
/// - Author: TetureSwiftSupport
3331
open class NamedDisplayCellNodeBase: ASCellNode {
3432

35-
private var __actionHandlers: [(NamedDisplayCellNodeBase, DisplayNodeAction) -> Void] = []
33+
private var __actionHandlers: [@MainActor (NamedDisplayCellNodeBase, DisplayNodeAction) -> Void] = []
3634

3735
@MainActor
3836
open override func didLoad() {
3937
super.didLoad()
4038
#if DEBUG
41-
queue.async { [weak self] in
39+
Task.detached { [weak self] in
4240
guard let self = self else { return }
4341
let typeName = _typeName(type(of: self))
44-
DispatchQueue.main.async {
42+
43+
Task { @MainActor in
4544
guard self.accessibilityIdentifier == nil else { return }
4645
self.accessibilityIdentifier = typeName
4746
}
@@ -56,7 +55,7 @@ open class NamedDisplayCellNodeBase: ASCellNode {
5655
- Warning: Non-atomic
5756
*/
5857
@discardableResult
59-
public func addNodeActionHandler(_ handler: @escaping (Self, DisplayNodeAction) -> Void) -> Self {
58+
public func addNodeActionHandler(_ handler: @escaping @MainActor (Self, DisplayNodeAction) -> Void) -> Self {
6059
__actionHandlers.append { node, action in
6160
guard let node = node as? Self else {
6261
assertionFailure()
@@ -68,6 +67,7 @@ open class NamedDisplayCellNodeBase: ASCellNode {
6867
return self
6968
}
7069

70+
@MainActor
7171
private func propagate(action: DisplayNodeAction) {
7272
for handler in __actionHandlers {
7373
handler(self, action)

Sources/Components/Tools/NamedDisplayNodeBase.swift

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
import AsyncDisplayKit
2323

24-
fileprivate let queue = DispatchQueue.global()
25-
2624
public enum DisplayNodeAction {
2725
case didLoad
2826
}
@@ -42,10 +40,10 @@ open class NamedDisplayNodeBase: ASDisplayNode {
4240
open override func didLoad() {
4341
super.didLoad()
4442
#if DEBUG
45-
queue.async { [weak self] in
43+
Task.detached { [weak self] in
4644
guard let self = self else { return }
4745
let typeName = _typeName(type(of: self))
48-
DispatchQueue.main.async {
46+
Task { @MainActor in
4947
guard self.accessibilityIdentifier == nil else { return }
5048
self.accessibilityIdentifier = typeName
5149
}
@@ -71,7 +69,6 @@ open class NamedDisplayNodeBase: ASDisplayNode {
7169
return self
7270
}
7371

74-
@preconcurrency
7572
@MainActor
7673
private func propagate(action: DisplayNodeAction) {
7774
for handler in __actionHandlers {
@@ -96,10 +93,10 @@ open class NamedDisplayControlNodeBase: ASControlNode {
9693
open override func didLoad() {
9794
super.didLoad()
9895
#if DEBUG
99-
queue.async { [weak self] in
96+
Task.detached { [weak self] in
10097
guard let self = self else { return }
10198
let typeName = _typeName(type(of: self))
102-
DispatchQueue.main.async {
99+
Task { @MainActor in
103100
guard self.accessibilityIdentifier == nil else { return }
104101
self.accessibilityIdentifier = typeName
105102
}
@@ -113,7 +110,7 @@ open class NamedDisplayControlNodeBase: ASControlNode {
113110
- Warning: Non-atomic
114111
*/
115112
@discardableResult
116-
public func addNodeActionHandler(_ handler: @escaping (Self, DisplayNodeAction) -> Void) -> Self {
113+
public func addNodeActionHandler(_ handler: @escaping @MainActor (Self, DisplayNodeAction) -> Void) -> Self {
117114
__actionHandlers.append { node, action in
118115
guard let node = node as? Self else {
119116
assertionFailure()

0 commit comments

Comments
 (0)