تخطَّ إلى المحتوى

Shared Mutable State In Task (ARCH9038)

هذا المحتوى غير متوفر بلغتك بعد.

Key swift.async.shared-mutable-state-in-task · Severity warning · Category async

Flags static / global vars mutated inside Task, DispatchQueue or Thread closures without an actor or lock.

static var hits = 0
Task { hits += 1 }
actor Counter { var hits = 0; func hit() { hits += 1 } }

Move the state into an actor, or guard it with a lock / serial queue.