Files
ichmagmaus111andClaude Opus 5.5 0622057a4f Ghostgram: open-source release
Ghostgram for iOS, rebuilt from scratch on Telegram iOS 13.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 17:57:09 +01:00

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
}
}