mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-12 01:10:49 +00:00
Let ASNodeController conform to NSLocking (#1179)
This commit is contained in:
parent
776e475558
commit
cb154f1471
@ -61,6 +61,7 @@
|
|||||||
- Fix mismatch in UIAccessibilityAction selector method [Michael Schneider](https://github.com/maicki) [#1169](https://github.com/TextureGroup/Texture/pull/1169)
|
- Fix mismatch in UIAccessibilityAction selector method [Michael Schneider](https://github.com/maicki) [#1169](https://github.com/TextureGroup/Texture/pull/1169)
|
||||||
- [ASDisplayNode] Expose default Texture-set accessibility values as properties. [Jia Wern Lim](https://github.com/jiawernlim) [#1170](https://github.com/TextureGroup/Texture/pull/1170)
|
- [ASDisplayNode] Expose default Texture-set accessibility values as properties. [Jia Wern Lim](https://github.com/jiawernlim) [#1170](https://github.com/TextureGroup/Texture/pull/1170)
|
||||||
- ASTableNode init method match checks from ASCollectionNode [Michael Schneider](https://github.com/maicki) [#1171]
|
- ASTableNode init method match checks from ASCollectionNode [Michael Schneider](https://github.com/maicki) [#1171]
|
||||||
|
- Add NSLocking conformance to ASNodeController [Michael Schneider](https://github.com/maicki)[#1179] (https://github.com/TextureGroup/Texture/pull/1179)
|
||||||
|
|
||||||
## 2.7
|
## 2.7
|
||||||
- Fix pager node for interface coalescing. [Max Wang](https://github.com/wsdwsd0829) [#877](https://github.com/TextureGroup/Texture/pull/877)
|
- Fix pager node for interface coalescing. [Max Wang](https://github.com/wsdwsd0829) [#877](https://github.com/TextureGroup/Texture/pull/877)
|
||||||
|
|||||||
@ -11,7 +11,8 @@
|
|||||||
#import <AsyncDisplayKit/ASDisplayNode+Subclasses.h> // for ASInterfaceState protocol
|
#import <AsyncDisplayKit/ASDisplayNode+Subclasses.h> // for ASInterfaceState protocol
|
||||||
|
|
||||||
/* ASNodeController is currently beta and open to change in the future */
|
/* ASNodeController is currently beta and open to change in the future */
|
||||||
@interface ASNodeController<__covariant DisplayNodeType : ASDisplayNode *> : NSObject <ASInterfaceStateDelegate>
|
@interface ASNodeController<__covariant DisplayNodeType : ASDisplayNode *>
|
||||||
|
: NSObject <ASInterfaceStateDelegate, NSLocking>
|
||||||
|
|
||||||
@property (nonatomic, strong /* may be weak! */) DisplayNodeType node;
|
@property (nonatomic, strong /* may be weak! */) DisplayNodeType node;
|
||||||
|
|
||||||
|
|||||||
@ -7,10 +7,11 @@
|
|||||||
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
|
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
|
|
||||||
#import <AsyncDisplayKit/ASInternalHelpers.h>
|
|
||||||
#import <AsyncDisplayKit/ASDisplayNodeInternal.h>
|
#import <AsyncDisplayKit/ASDisplayNodeInternal.h>
|
||||||
#import <AsyncDisplayKit/ASDisplayNode+FrameworkPrivate.h>
|
#import <AsyncDisplayKit/ASDisplayNode+FrameworkPrivate.h>
|
||||||
#import <AsyncDisplayKit/ASNodeController+Beta.h>
|
#import <AsyncDisplayKit/ASNodeController+Beta.h>
|
||||||
|
#import <AsyncDisplayKit/ASThread.h>
|
||||||
|
#import <AsyncDisplayKit/ASWeakProxy.h>
|
||||||
|
|
||||||
#define _node (_shouldInvertStrongReference ? _weakNode : _strongNode)
|
#define _node (_shouldInvertStrongReference ? _weakNode : _strongNode)
|
||||||
|
|
||||||
@ -18,15 +19,18 @@
|
|||||||
{
|
{
|
||||||
ASDisplayNode *_strongNode;
|
ASDisplayNode *_strongNode;
|
||||||
__weak ASDisplayNode *_weakNode;
|
__weak ASDisplayNode *_weakNode;
|
||||||
|
ASDN::RecursiveMutex __instanceLock__;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)loadNode
|
- (void)loadNode
|
||||||
{
|
{
|
||||||
|
ASLockScopeSelf();
|
||||||
self.node = [[ASDisplayNode alloc] init];
|
self.node = [[ASDisplayNode alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ASDisplayNode *)node
|
- (ASDisplayNode *)node
|
||||||
{
|
{
|
||||||
|
ASLockScopeSelf();
|
||||||
if (_node == nil) {
|
if (_node == nil) {
|
||||||
[self loadNode];
|
[self loadNode];
|
||||||
}
|
}
|
||||||
@ -35,6 +39,7 @@
|
|||||||
|
|
||||||
- (void)setupReferencesWithNode:(ASDisplayNode *)node
|
- (void)setupReferencesWithNode:(ASDisplayNode *)node
|
||||||
{
|
{
|
||||||
|
ASLockScopeSelf();
|
||||||
if (_shouldInvertStrongReference) {
|
if (_shouldInvertStrongReference) {
|
||||||
// The node should own the controller; weak reference from controller to node.
|
// The node should own the controller; weak reference from controller to node.
|
||||||
_weakNode = node;
|
_weakNode = node;
|
||||||
@ -51,11 +56,13 @@
|
|||||||
|
|
||||||
- (void)setNode:(ASDisplayNode *)node
|
- (void)setNode:(ASDisplayNode *)node
|
||||||
{
|
{
|
||||||
|
ASLockScopeSelf();
|
||||||
[self setupReferencesWithNode:node];
|
[self setupReferencesWithNode:node];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setShouldInvertStrongReference:(BOOL)shouldInvertStrongReference
|
- (void)setShouldInvertStrongReference:(BOOL)shouldInvertStrongReference
|
||||||
{
|
{
|
||||||
|
ASLockScopeSelf();
|
||||||
if (_shouldInvertStrongReference != shouldInvertStrongReference) {
|
if (_shouldInvertStrongReference != shouldInvertStrongReference) {
|
||||||
// Because the BOOL controls which ivar we access, get the node before toggling.
|
// Because the BOOL controls which ivar we access, get the node before toggling.
|
||||||
ASDisplayNode *node = _node;
|
ASDisplayNode *node = _node;
|
||||||
@ -82,11 +89,24 @@
|
|||||||
|
|
||||||
- (void)hierarchyDisplayDidFinish {}
|
- (void)hierarchyDisplayDidFinish {}
|
||||||
|
|
||||||
|
#pragma mark NSLocking
|
||||||
|
|
||||||
|
- (void)lock
|
||||||
|
{
|
||||||
|
__instanceLock__.lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)unlock
|
||||||
|
{
|
||||||
|
__instanceLock__.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation ASDisplayNode (ASNodeController)
|
@implementation ASDisplayNode (ASNodeController)
|
||||||
|
|
||||||
- (ASNodeController *)nodeController {
|
- (ASNodeController *)nodeController
|
||||||
|
{
|
||||||
return _weakNodeController ?: _strongNodeController;
|
return _weakNodeController ?: _strongNodeController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user