From 7cdfacca4a989e795bd2019e0825b819cf8b74a7 Mon Sep 17 00:00:00 2001 From: Huy Nguyen Date: Sun, 14 Oct 2018 09:16:47 -0700 Subject: [PATCH] Update documentation of ASNetworkImageNodeDelegate #trivial (#1163) `-imageNodeDidStartFetchingData:` and `-imageNodeDidFinishDecoding:` are always called on main thread, and the documentation should reflect that. --- Source/ASNetworkImageNode.h | 20 +++++++++++--------- Source/ASNetworkImageNode.mm | 2 ++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Source/ASNetworkImageNode.h b/Source/ASNetworkImageNode.h index f77a9a59d1..576cbb94b8 100644 --- a/Source/ASNetworkImageNode.h +++ b/Source/ASNetworkImageNode.h @@ -145,6 +145,15 @@ NS_ASSUME_NONNULL_BEGIN @protocol ASNetworkImageNodeDelegate @optional +/** + * Notification that the image node started to load + * + * @param imageNode The sender. + * + * @discussion Called on the main thread. + */ +- (void)imageNodeDidStartFetchingData:(ASNetworkImageNode *)imageNode; + /** * Notification that the image node finished downloading an image, with additional info. * If implemented, this method will be called instead of `imageNode:didLoadImage:`. @@ -167,15 +176,6 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)imageNode:(ASNetworkImageNode *)imageNode didLoadImage:(UIImage *)image; -/** - * Notification that the image node started to load - * - * @param imageNode The sender. - * - * @discussion Called on a background queue. - */ -- (void)imageNodeDidStartFetchingData:(ASNetworkImageNode *)imageNode; - /** * Notification that the image node failed to download the image. * @@ -190,6 +190,8 @@ NS_ASSUME_NONNULL_BEGIN * Notification that the image node finished decoding an image. * * @param imageNode The sender. + * + * @discussion Called on the main thread. */ - (void)imageNodeDidFinishDecoding:(ASNetworkImageNode *)imageNode; diff --git a/Source/ASNetworkImageNode.mm b/Source/ASNetworkImageNode.mm index ce864647af..ea863c1ee1 100644 --- a/Source/ASNetworkImageNode.mm +++ b/Source/ASNetworkImageNode.mm @@ -614,6 +614,8 @@ static std::atomic_bool _useMainThreadDelegateCallbacks(true); - (void)_lazilyLoadImageIfNecessary { + ASDisplayNodeAssertMainThread(); + [self lock]; __weak id delegate = _delegate; BOOL delegateDidStartFetchingData = _delegateFlags.delegateDidStartFetchingData;