From dce8d3061d801a70ebc486a68ea8986223589d3a Mon Sep 17 00:00:00 2001 From: Mourad Date: Tue, 19 Sep 2017 11:42:54 +0200 Subject: [PATCH] Fix completed var thread safety problem --- Bolts/Common/BFTask.m | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Bolts/Common/BFTask.m b/Bolts/Common/BFTask.m index 0d6bd4cda..aae914690 100644 --- a/Bolts/Common/BFTask.m +++ b/Bolts/Common/BFTask.m @@ -424,13 +424,11 @@ - (void)waitUntilFinished { return; } [self.condition lock]; + while (!self.completed) { + [self.condition wait]; + } + [self.condition unlock]; } - // TODO: (nlutsenko) Restructure this to use Bolts-Swift thread access synchronization architecture - // In the meantime, it's absolutely safe to get `_completed` aka an ivar, as long as it's a `BOOL` aka less than word size. - while (!_completed) { - [self.condition wait]; - } - [self.condition unlock]; } #pragma mark - NSObject