From 689029be0cc136539dd9aef9b294aa10b4c4ed1d Mon Sep 17 00:00:00 2001 From: Muukii Date: Tue, 5 Mar 2024 00:56:22 +0900 Subject: [PATCH] WIP --- Sources/Verge/Library/EventEmitter.swift | 4 ++-- Sources/Verge/Library/StoreSubscription.swift | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Sources/Verge/Library/EventEmitter.swift b/Sources/Verge/Library/EventEmitter.swift index f9203e6a80..2993b4c6d6 100644 --- a/Sources/Verge/Library/EventEmitter.swift +++ b/Sources/Verge/Library/EventEmitter.swift @@ -25,7 +25,7 @@ import Foundation import os import DequeModule -public final class EventEmitterCancellable: Hashable, CancellableType { +public final class EventEmitterCancellable: Hashable, Cancellable, @unchecked Sendable { public static func == (lhs: EventEmitterCancellable, rhs: EventEmitterCancellable) -> Bool { lhs === rhs @@ -46,7 +46,7 @@ public final class EventEmitterCancellable: Hashable, CancellableType { } } -protocol EventEmitterType: AnyObject { +protocol EventEmitterType: AnyObject, Sendable { func removeEventHandler(_ token: EventEmitterCancellable) } diff --git a/Sources/Verge/Library/StoreSubscription.swift b/Sources/Verge/Library/StoreSubscription.swift index 77cc87ea32..39ab7eb15c 100644 --- a/Sources/Verge/Library/StoreSubscription.swift +++ b/Sources/Verge/Library/StoreSubscription.swift @@ -5,7 +5,7 @@ import Combine A subscription that is compatible with Combine’s Cancellable. You can manage asynchronous tasks either call the ``cancel()`` to halt the subscription, or allow it to terminate upon instance deallocation, and by implementing the ``storeWhileSourceActive()`` technique, the subscription’s active status is maintained until the source store is released. */ -public final class StoreSubscription: Hashable, Cancellable { +public final class StoreSubscription: Hashable, Cancellable, @unchecked Sendable { public static func == (lhs: StoreSubscription, rhs: StoreSubscription) -> Bool { lhs === rhs @@ -18,6 +18,8 @@ public final class StoreSubscription: Hashable, Cancellable { private let wasCancelled = ManagedAtomic(false) private let source: EventEmitterCancellable + + // TODO: can't be sendable private weak var storeCancellable: VergeAnyCancellable? private var associatedStore: (any StoreType)? private var associatedReferences: [AnyObject] = [] @@ -38,6 +40,14 @@ public final class StoreSubscription: Hashable, Cancellable { associatedStore = nil } + public func suspend() { + + } + + public func resume() { + + } + func associate(store: some StoreType) -> StoreSubscription { ensureAlive() associatedStore = store