mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-11-03 22:27:13 +01:00
Ghostgram for iOS, rebuilt from scratch on Telegram iOS 13.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
27 lines
879 B
Swift
27 lines
879 B
Swift
import Foundation
|
|
|
|
/// Tracks which holders currently want the WEB carrier running.
|
|
///
|
|
/// The carrier is process-wide and serves every account, so start and stop must be
|
|
/// idempotent: `set` reports whether this call actually changed the aggregate
|
|
/// answer, letting the transport ignore the many no-op updates that arrive as
|
|
/// individual accounts come and go.
|
|
struct WebProxyDemandSet {
|
|
private var tokens = Set<AnyHashable>()
|
|
|
|
var isEmpty: Bool {
|
|
return self.tokens.isEmpty
|
|
}
|
|
|
|
/// Adds or removes one holder. Returns true when `isEmpty` flipped as a result.
|
|
mutating func set(_ token: AnyHashable, wanted: Bool) -> Bool {
|
|
let wasEmpty = self.tokens.isEmpty
|
|
if wanted {
|
|
self.tokens.insert(token)
|
|
} else {
|
|
self.tokens.remove(token)
|
|
}
|
|
return wasEmpty != self.tokens.isEmpty
|
|
}
|
|
}
|