Flipboard / Flipboard/NSUserDefaultsSimulatorPerformanceBoost

dispatch_barrier_async can lead to inconsistent values when using mutable objects

Đang mở
#2 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Objective-C
Star
40
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

dispatch_barrier_async works great for this project, except for the following situation:
1. NSMutableDictionary *registeredDefaults = [[NSMutableDictionary alloc] init];
2. [[NSUserDefaults standardUserDefaults] registerDefaults:registeredDefaults];
3. [registeredDefaults setObject:@"FOO" forKey:@"BAR"];
4. NSObject *value = [[NSUserDefaults standardUserDefaults] objectForKey:@"BAR"];
- With sim performance ON, value may be equal to nil or equal to @"FOO" depending on if line 3 executed before the internal barrier_async block executed.
- With sim performance OFF, value is always equal to nil. Mutations after line 2 are not acknowledged.

The code above is incorrect anyways (you wouldn't expect it to work) -- but we still need to honor the behavior of NSUserDefaults. You could emulate this bug using -setObject:forKey: with a mutable object.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.