Flipboard / Flipboard/NSUserDefaultsSimulatorPerformanceBoost

dispatch_barrier_async can lead to inconsistent values when using mutable objects

オープン
#2 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Objective-C
スター
40
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。