Make delegateDelay property atomic and access it via self.

PiperOrigin-RevId: 832080864
This commit is contained in:
Edwin Wu
2025-11-13 18:00:52 -08:00
committed by Copybara-Service
parent 2d272f59ea
commit 8375b82a86
2 changed files with 4 additions and 3 deletions
@@ -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.
@@ -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();
});