mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-03-27 22:46:35 +08:00
Remove ASSentinel (#2336)
This commit is contained in:
@@ -56,7 +56,6 @@
|
||||
058D0A29195D050800B7D73C /* ASDisplayNode+DebugTiming.mm in Sources */ = {isa = PBXBuildFile; fileRef = 058D0A0A195D050800B7D73C /* ASDisplayNode+DebugTiming.mm */; };
|
||||
058D0A2A195D050800B7D73C /* ASDisplayNode+UIViewBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 058D0A0B195D050800B7D73C /* ASDisplayNode+UIViewBridge.mm */; };
|
||||
058D0A2B195D050800B7D73C /* ASImageNode+CGExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 058D0A0E195D050800B7D73C /* ASImageNode+CGExtras.m */; };
|
||||
058D0A2C195D050800B7D73C /* ASSentinel.m in Sources */ = {isa = PBXBuildFile; fileRef = 058D0A11195D050800B7D73C /* ASSentinel.m */; };
|
||||
058D0A38195D057000B7D73C /* ASDisplayLayerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 058D0A2D195D057000B7D73C /* ASDisplayLayerTests.m */; };
|
||||
058D0A39195D057000B7D73C /* ASDisplayNodeAppearanceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 058D0A2E195D057000B7D73C /* ASDisplayNodeAppearanceTests.m */; };
|
||||
058D0A3A195D057000B7D73C /* ASDisplayNodeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 058D0A2F195D057000B7D73C /* ASDisplayNodeTests.m */; };
|
||||
@@ -410,8 +409,6 @@
|
||||
B35062521B010EFD0018CF92 /* ASDisplayNodeInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 058D0A0C195D050800B7D73C /* ASDisplayNodeInternal.h */; };
|
||||
B35062531B010EFD0018CF92 /* ASImageNode+CGExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 058D0A0D195D050800B7D73C /* ASImageNode+CGExtras.h */; };
|
||||
B35062541B010EFD0018CF92 /* ASImageNode+CGExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 058D0A0E195D050800B7D73C /* ASImageNode+CGExtras.m */; };
|
||||
B35062551B010EFD0018CF92 /* ASSentinel.h in Headers */ = {isa = PBXBuildFile; fileRef = 058D0A10195D050800B7D73C /* ASSentinel.h */; };
|
||||
B35062561B010EFD0018CF92 /* ASSentinel.m in Sources */ = {isa = PBXBuildFile; fileRef = 058D0A11195D050800B7D73C /* ASSentinel.m */; };
|
||||
B35062571B010F070018CF92 /* ASAssert.h in Headers */ = {isa = PBXBuildFile; fileRef = 058D0A43195D058D00B7D73C /* ASAssert.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
B35062581B010F070018CF92 /* ASAvailability.h in Headers */ = {isa = PBXBuildFile; fileRef = 0516FA3A1A15563400B4EBED /* ASAvailability.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
B35062591B010F070018CF92 /* ASBaseDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = 058D0A44195D058D00B7D73C /* ASBaseDefines.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@@ -614,7 +611,6 @@
|
||||
F7CE6C991D2CDB5800BE4C15 /* ASLayoutSpecUtilities.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = ACF6ED451B17847A00DA7C62 /* ASLayoutSpecUtilities.h */; };
|
||||
F7CE6C9A1D2CDB5800BE4C15 /* ASMultidimensionalArrayUtils.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 0442850B1BAA64EC00D16268 /* ASMultidimensionalArrayUtils.h */; };
|
||||
F7CE6C9B1D2CDB5800BE4C15 /* ASPendingStateController.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = CC3B20811C3F76D600798563 /* ASPendingStateController.h */; };
|
||||
F7CE6C9C1D2CDB5800BE4C15 /* ASSentinel.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 058D0A10195D050800B7D73C /* ASSentinel.h */; };
|
||||
F7CE6C9D1D2CDB5800BE4C15 /* ASStackBaselinePositionedLayout.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9C8221931BA237B80037F19A /* ASStackBaselinePositionedLayout.h */; };
|
||||
F7CE6C9E1D2CDB5800BE4C15 /* ASStackLayoutSpecUtilities.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = ACF6ED461B17847A00DA7C62 /* ASStackLayoutSpecUtilities.h */; };
|
||||
F7CE6C9F1D2CDB5800BE4C15 /* ASStackPositionedLayout.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = ACF6ED471B17847A00DA7C62 /* ASStackPositionedLayout.h */; };
|
||||
@@ -788,7 +784,6 @@
|
||||
F7CE6C991D2CDB5800BE4C15 /* ASLayoutSpecUtilities.h in CopyFiles */,
|
||||
F7CE6C9A1D2CDB5800BE4C15 /* ASMultidimensionalArrayUtils.h in CopyFiles */,
|
||||
F7CE6C9B1D2CDB5800BE4C15 /* ASPendingStateController.h in CopyFiles */,
|
||||
F7CE6C9C1D2CDB5800BE4C15 /* ASSentinel.h in CopyFiles */,
|
||||
F7CE6C9D1D2CDB5800BE4C15 /* ASStackBaselinePositionedLayout.h in CopyFiles */,
|
||||
F7CE6C9E1D2CDB5800BE4C15 /* ASStackLayoutSpecUtilities.h in CopyFiles */,
|
||||
F7CE6C9F1D2CDB5800BE4C15 /* ASStackPositionedLayout.h in CopyFiles */,
|
||||
@@ -885,8 +880,6 @@
|
||||
058D0A0C195D050800B7D73C /* ASDisplayNodeInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASDisplayNodeInternal.h; sourceTree = "<group>"; };
|
||||
058D0A0D195D050800B7D73C /* ASImageNode+CGExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASImageNode+CGExtras.h"; sourceTree = "<group>"; };
|
||||
058D0A0E195D050800B7D73C /* ASImageNode+CGExtras.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ASImageNode+CGExtras.m"; sourceTree = "<group>"; };
|
||||
058D0A10195D050800B7D73C /* ASSentinel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASSentinel.h; sourceTree = "<group>"; };
|
||||
058D0A11195D050800B7D73C /* ASSentinel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASSentinel.m; sourceTree = "<group>"; };
|
||||
058D0A12195D050800B7D73C /* ASThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASThread.h; sourceTree = "<group>"; };
|
||||
058D0A2D195D057000B7D73C /* ASDisplayLayerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASDisplayLayerTests.m; sourceTree = "<group>"; };
|
||||
058D0A2E195D057000B7D73C /* ASDisplayNodeAppearanceTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASDisplayNodeAppearanceTests.m; sourceTree = "<group>"; };
|
||||
@@ -1581,8 +1574,6 @@
|
||||
CC446A2E1D80AAE00071FD03 /* ASObjectDescriptionHelpers.m */,
|
||||
CC3B20811C3F76D600798563 /* ASPendingStateController.h */,
|
||||
CC3B20821C3F76D600798563 /* ASPendingStateController.mm */,
|
||||
058D0A10195D050800B7D73C /* ASSentinel.h */,
|
||||
058D0A11195D050800B7D73C /* ASSentinel.m */,
|
||||
9C8221931BA237B80037F19A /* ASStackBaselinePositionedLayout.h */,
|
||||
9C8221941BA237B80037F19A /* ASStackBaselinePositionedLayout.mm */,
|
||||
ACF6ED461B17847A00DA7C62 /* ASStackLayoutSpecUtilities.h */,
|
||||
@@ -1880,7 +1871,6 @@
|
||||
683489281D70DE3400327501 /* ASDisplayNode+Deprecated.h in Headers */,
|
||||
B35062081B010EFD0018CF92 /* ASScrollNode.h in Headers */,
|
||||
25E327571C16819500A2170C /* ASPagerNode.h in Headers */,
|
||||
B35062551B010EFD0018CF92 /* ASSentinel.h in Headers */,
|
||||
9C8221961BA237B80037F19A /* ASStackBaselinePositionedLayout.h in Headers */,
|
||||
9C70F20E1CDBE9E5007D6C76 /* NSArray+Diffing.h in Headers */,
|
||||
9C49C3701B853961000B0DD5 /* ASStackLayoutElement.h in Headers */,
|
||||
@@ -2218,7 +2208,6 @@
|
||||
9C8898BB1C738B9800D6B02E /* ASTextKitFontSizeAdjuster.mm in Sources */,
|
||||
D785F6631A74327E00291744 /* ASScrollNode.m in Sources */,
|
||||
E5711A2E1C840C96009619D4 /* ASIndexedNodeContext.mm in Sources */,
|
||||
058D0A2C195D050800B7D73C /* ASSentinel.m in Sources */,
|
||||
9C8221971BA237B80037F19A /* ASStackBaselinePositionedLayout.mm in Sources */,
|
||||
251B8EF81BBB3D690087C538 /* ASCollectionDataController.mm in Sources */,
|
||||
ACF6ED301B17843500DA7C62 /* ASStackLayoutSpec.mm in Sources */,
|
||||
@@ -2405,7 +2394,6 @@
|
||||
254C6B851BF94F8A003EC431 /* ASTextKitAttributes.mm in Sources */,
|
||||
509E68601B3AED8E009B9150 /* ASScrollDirection.m in Sources */,
|
||||
B35062091B010EFD0018CF92 /* ASScrollNode.m in Sources */,
|
||||
B35062561B010EFD0018CF92 /* ASSentinel.m in Sources */,
|
||||
9C8221981BA237B80037F19A /* ASStackBaselinePositionedLayout.mm in Sources */,
|
||||
8BDA5FC81CDBDF95007D13B2 /* ASVideoPlayerNode.mm in Sources */,
|
||||
34EFC7721B701D0300AD841F /* ASStackLayoutSpec.mm in Sources */,
|
||||
|
||||
@@ -297,7 +297,6 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
[self _staticInitialize];
|
||||
_eventLogHead = -1;
|
||||
_contentsScaleForDisplay = ASScreenScale();
|
||||
_displaySentinel = [[ASSentinel alloc] init];
|
||||
|
||||
// TODO: We should lazily initialize the style object.
|
||||
_style = [[ASLayoutElementStyle alloc] init];
|
||||
@@ -439,8 +438,6 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
[self __setSupernode:nil];
|
||||
_pendingViewState = nil;
|
||||
|
||||
_displaySentinel = nil;
|
||||
|
||||
_pendingDisplayNodes = nil;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
|
||||
@class ASSentinel;
|
||||
@protocol _ASDisplayLayerDelegate;
|
||||
|
||||
// Type for the cancellation checker block passed into the async display blocks. YES means the operation has been cancelled, NO means continue.
|
||||
@@ -41,8 +39,6 @@ typedef BOOL(^asdisplaynode_iscancelled_block_t)(void);
|
||||
*/
|
||||
+ (dispatch_queue_t)displayQueue;
|
||||
|
||||
@property (nonatomic, strong, readonly) ASSentinel *displaySentinel;
|
||||
|
||||
/**
|
||||
@summary Delegate for asynchronous display of the layer.
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_displaySentinel = [[ASSentinel alloc] init];
|
||||
|
||||
self.opaque = YES;
|
||||
}
|
||||
@@ -225,7 +224,6 @@
|
||||
- (void)cancelAsyncDisplay
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
[_displaySentinel increment];
|
||||
|
||||
id<_ASDisplayLayerDelegate> NS_VALID_UNTIL_END_OF_SCOPE strongAsyncDelegate;
|
||||
{
|
||||
|
||||
@@ -267,16 +267,23 @@
|
||||
|
||||
// for async display, capture the current displaySentinel value to bail early when the job is executed if another is
|
||||
// enqueued
|
||||
// for sync display, just use nil for the displaySentinel and go
|
||||
// for sync display, do not support cancellation
|
||||
|
||||
// FIXME: what about the degenerate case where we are calling setNeedsDisplay faster than the jobs are dequeuing
|
||||
// from the displayQueue? Need to not cancel early fails from displaySentinel changes.
|
||||
ASSentinel *displaySentinel = (asynchronously ? _displaySentinel : nil);
|
||||
int32_t displaySentinelValue = [displaySentinel increment];
|
||||
|
||||
asdisplaynode_iscancelled_block_t isCancelledBlock = ^{
|
||||
return BOOL(displaySentinelValue != displaySentinel.value);
|
||||
};
|
||||
asdisplaynode_iscancelled_block_t isCancelledBlock = nil;
|
||||
if (asynchronously) {
|
||||
uint displaySentinelValue = ++_displaySentinel;
|
||||
__weak ASDisplayNode *weakSelf = self;
|
||||
isCancelledBlock = ^{
|
||||
__strong ASDisplayNode *self = weakSelf;
|
||||
return self == nil || (displaySentinelValue != self->_displaySentinel.load());
|
||||
};
|
||||
} else {
|
||||
isCancelledBlock = ^{
|
||||
return NO;
|
||||
};
|
||||
}
|
||||
|
||||
// Set up displayBlock to call either display or draw on the delegate and return a UIImage contents
|
||||
asyncdisplaykit_async_transaction_operation_block_t displayBlock = [self _displayBlockWithAsynchronous:asynchronously isCancelledBlock:isCancelledBlock rasterizing:NO];
|
||||
@@ -329,7 +336,7 @@
|
||||
|
||||
- (void)cancelDisplayAsyncLayer:(_ASDisplayLayer *)asyncLayer
|
||||
{
|
||||
[_displaySentinel increment];
|
||||
_displaySentinel.fetch_add(1);
|
||||
}
|
||||
|
||||
- (ASDisplayNodeContextModifier)willDisplayNodeContentWithRenderingContext
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
#import "_AS-objc-internal.h"
|
||||
#import "ASDisplayNode.h"
|
||||
#import "ASSentinel.h"
|
||||
#import "ASThread.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
// These methods must never be called or overridden by other classes.
|
||||
//
|
||||
|
||||
#import <atomic>
|
||||
#import "_AS-objc-internal.h"
|
||||
#import "ASDisplayNode.h"
|
||||
#import "ASSentinel.h"
|
||||
#import "ASThread.h"
|
||||
#import "_ASTransitionContext.h"
|
||||
#import "ASLayoutTransition.h"
|
||||
@@ -109,7 +109,7 @@ FOUNDATION_EXPORT NSString * const ASRenderingEngineDidDisplayNodesScheduledBefo
|
||||
|
||||
ASLayoutElementStyle *_style;
|
||||
|
||||
ASSentinel *_displaySentinel;
|
||||
std::atomic_uint _displaySentinel;
|
||||
|
||||
int32_t _transitionID;
|
||||
BOOL _transitionInProgress;
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// ASSentinel.h
|
||||
// AsyncDisplayKit
|
||||
//
|
||||
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
// This source code is licensed under the BSD-style license found in the
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
@summary We want to avoid capturing layer instances on a background queue, but we want a way to cancel rendering
|
||||
immediately if another display pass begins. ASSentinel is owned by the layer and passed to the background
|
||||
block.
|
||||
*/
|
||||
@interface ASSentinel : NSObject
|
||||
|
||||
/**
|
||||
Returns the current value of the sentinel.
|
||||
*/
|
||||
- (int32_t)value;
|
||||
|
||||
/**
|
||||
Atomically increments the value and returns the new value.
|
||||
*/
|
||||
- (int32_t)increment;
|
||||
|
||||
@end
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// ASSentinel.m
|
||||
// AsyncDisplayKit
|
||||
//
|
||||
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
// This source code is licensed under the BSD-style license found in the
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
//
|
||||
|
||||
#import "ASSentinel.h"
|
||||
|
||||
#import <libkern/OSAtomic.h>
|
||||
|
||||
@implementation ASSentinel
|
||||
{
|
||||
int32_t _value;
|
||||
}
|
||||
|
||||
- (int32_t)value
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
- (int32_t)increment
|
||||
{
|
||||
return OSAtomicAdd32(1, &_value);
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user