From 8375b82a86b81f7926b217ebb5984f535cc99f92 Mon Sep 17 00:00:00 2001 From: Edwin Wu Date: Thu, 13 Nov 2025 17:59:02 -0800 Subject: [PATCH] Make `delegateDelay` property atomic and access it via `self`. PiperOrigin-RevId: 832080864 --- .../apple/Mediums/BLE/Tests/GNCFakePeripheral.h | 2 +- .../apple/Mediums/BLE/Tests/GNCFakePeripheral.m | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/platform/implementation/apple/Mediums/BLE/Tests/GNCFakePeripheral.h b/internal/platform/implementation/apple/Mediums/BLE/Tests/GNCFakePeripheral.h index 866968e8..adf449e6 100644 --- a/internal/platform/implementation/apple/Mediums/BLE/Tests/GNCFakePeripheral.h +++ b/internal/platform/implementation/apple/Mediums/BLE/Tests/GNCFakePeripheral.h @@ -56,7 +56,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, nullable, readwrite) NSError *readValueForCharacteristicError; /** Similates a delay in all delegate calls by the specified amount. */ -@property(nonatomic, readwrite) NSTimeInterval delegateDelay; +@property(readwrite) NSTimeInterval delegateDelay; /** * Similates a @c openL2CAPChannelWithPSM: error. diff --git a/internal/platform/implementation/apple/Mediums/BLE/Tests/GNCFakePeripheral.m b/internal/platform/implementation/apple/Mediums/BLE/Tests/GNCFakePeripheral.m index 971977ab..916b6495 100644 --- a/internal/platform/implementation/apple/Mediums/BLE/Tests/GNCFakePeripheral.m +++ b/internal/platform/implementation/apple/Mediums/BLE/Tests/GNCFakePeripheral.m @@ -136,10 +136,11 @@ NS_ASSUME_NONNULL_BEGIN } - (void)delayDelegateUsingBlock:(void (^)())block { - if (_delegateDelay <= 0) { + NSTimeInterval delegateDelay = self.delegateDelay; + if (delegateDelay <= 0) { block(); } else { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, _delegateDelay * NSEC_PER_SEC), + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delegateDelay * NSEC_PER_SEC), dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0), ^{ block(); });