mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-27 10:32:37 +00:00
Merge pull request #689 from facebook/Synchrotron
Implementation of Synchronous Concurrency features for AsyncDisplayKit 2.0
This commit is contained in:
commit
c8518c7fa6
@ -14,6 +14,29 @@
|
|||||||
*/
|
*/
|
||||||
@interface ASCellNode : ASDisplayNode
|
@interface ASCellNode : ASDisplayNode
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @abstract When enabled, ensures that the cell is completely displayed before allowed onscreen.
|
||||||
|
*
|
||||||
|
* @default NO
|
||||||
|
* @discussion Normally, ASCellNodes are preloaded and have finished display before they are onscreen.
|
||||||
|
* However, if the Table or Collection's rangeTuningParameters are set to small values (or 0),
|
||||||
|
* or if the user is scrolling rapidly on a slow device, it is possible for a cell's display to
|
||||||
|
* be incomplete when it becomes visible.
|
||||||
|
*
|
||||||
|
* In this case, normally placeholder states are shown and scrolling continues uninterrupted.
|
||||||
|
* The finished, drawn content is then shown as soon as it is ready.
|
||||||
|
*
|
||||||
|
* With this property set to YES, the main thread will be blocked until display is complete for
|
||||||
|
* the cell. This is more similar to UIKit, and in fact makes AsyncDisplayKit scrolling visually
|
||||||
|
* indistinguishible from UIKit's, except being faster.
|
||||||
|
*
|
||||||
|
* Using this option does not eliminate all of the performance advantages of AsyncDisplayKit.
|
||||||
|
* Normally, a cell has been preloading and is almost done when it reaches the screen, so the
|
||||||
|
* blocking time is very short. If the rangeTuningParameters are set to 0, still this option
|
||||||
|
* outperforms UIKit: while the main thread is waiting, subnode display executes concurrently.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) BOOL neverShowPlaceholders;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ASTableView uses these properties when configuring UITableViewCells that host ASCellNodes.
|
* ASTableView uses these properties when configuring UITableViewCells that host ASCellNodes.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -212,6 +212,15 @@
|
|||||||
*/
|
*/
|
||||||
- (ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath;
|
- (ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to -indexPathForCell:.
|
||||||
|
*
|
||||||
|
* @param cellNode a cellNode part of the table view
|
||||||
|
*
|
||||||
|
* @returns an indexPath for this cellNode
|
||||||
|
*/
|
||||||
|
- (NSIndexPath *)indexPathForNode:(ASCellNode *)cellNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to -visibleCells.
|
* Similar to -visibleCells.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -17,6 +17,9 @@
|
|||||||
#import "UICollectionViewLayout+ASConvenience.h"
|
#import "UICollectionViewLayout+ASConvenience.h"
|
||||||
#import "ASInternalHelpers.h"
|
#import "ASInternalHelpers.h"
|
||||||
|
|
||||||
|
// FIXME: Temporary nonsense import until method names are finalized and exposed
|
||||||
|
#import "ASDisplayNode+Subclasses.h"
|
||||||
|
|
||||||
const static NSUInteger kASCollectionViewAnimationNone = UITableViewRowAnimationNone;
|
const static NSUInteger kASCollectionViewAnimationNone = UITableViewRowAnimationNone;
|
||||||
|
|
||||||
|
|
||||||
@ -315,6 +318,16 @@ static BOOL _isInterceptedSelector(SEL sel)
|
|||||||
return [[_dataController nodeAtIndexPath:indexPath] calculatedSize];
|
return [[_dataController nodeAtIndexPath:indexPath] calculatedSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||||
|
{
|
||||||
|
return [_dataController nodeAtIndexPath:indexPath];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSIndexPath *)indexPathForNode:(ASCellNode *)cellNode
|
||||||
|
{
|
||||||
|
return [_dataController indexPathForNode:cellNode];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSArray *)visibleNodes
|
- (NSArray *)visibleNodes
|
||||||
{
|
{
|
||||||
NSArray *indexPaths = [self indexPathsForVisibleItems];
|
NSArray *indexPaths = [self indexPathsForVisibleItems];
|
||||||
@ -392,11 +405,6 @@ static BOOL _isInterceptedSelector(SEL sel)
|
|||||||
[_dataController moveRowAtIndexPath:indexPath toIndexPath:newIndexPath withAnimationOptions:kASCollectionViewAnimationNone];
|
[_dataController moveRowAtIndexPath:indexPath toIndexPath:newIndexPath withAnimationOptions:kASCollectionViewAnimationNone];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath
|
|
||||||
{
|
|
||||||
return [_dataController nodeAtIndexPath:indexPath];
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark Intercepted selectors.
|
#pragma mark Intercepted selectors.
|
||||||
|
|
||||||
@ -490,6 +498,11 @@ static BOOL _isInterceptedSelector(SEL sel)
|
|||||||
if ([_asyncDelegate respondsToSelector:@selector(collectionView:willDisplayNodeForItemAtIndexPath:)]) {
|
if ([_asyncDelegate respondsToSelector:@selector(collectionView:willDisplayNodeForItemAtIndexPath:)]) {
|
||||||
[_asyncDelegate collectionView:self willDisplayNodeForItemAtIndexPath:indexPath];
|
[_asyncDelegate collectionView:self willDisplayNodeForItemAtIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASCellNode *cellNode = [self nodeForItemAtIndexPath:indexPath];
|
||||||
|
if (cellNode.neverShowPlaceholders) {
|
||||||
|
[cellNode recursivelyEnsureDisplay];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
|
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
|
||||||
|
|||||||
@ -429,6 +429,38 @@
|
|||||||
// This method has proven helpful in a few rare scenarios, similar to a category extension on UIView,
|
// This method has proven helpful in a few rare scenarios, similar to a category extension on UIView,
|
||||||
// but it's considered private API for now and its use should not be encouraged.
|
// but it's considered private API for now and its use should not be encouraged.
|
||||||
- (ASDisplayNode *)_supernodeWithClass:(Class)supernodeClass;
|
- (ASDisplayNode *)_supernodeWithClass:(Class)supernodeClass;
|
||||||
|
|
||||||
|
// The two methods below will eventually be exposed, but their names are subject to change.
|
||||||
|
/**
|
||||||
|
* @abstract Ensure that all rendering is complete for this node and its descendents.
|
||||||
|
*
|
||||||
|
* @discussion Calling this method on the main thread after a node is added to the view heirarchy will ensure that
|
||||||
|
* placeholder states are never visible to the user. It is used by ASTableView, ASCollectionView, and ASViewController
|
||||||
|
* to implement their respective ".neverShowPlaceholders" option.
|
||||||
|
*
|
||||||
|
* If all nodes have layer.contents set and/or their layer does not have -needsDisplay set, the method will return immediately.
|
||||||
|
*
|
||||||
|
* This method is capable of handling a mixed set of nodes, with some not having started display, some in progress on an
|
||||||
|
* asynchronous display operation, and some already finished.
|
||||||
|
*
|
||||||
|
* In order to guarantee against deadlocks, this method should only be called on the main thread.
|
||||||
|
* It may block on the private queue, [_ASDisplayLayer displayQueue]
|
||||||
|
*/
|
||||||
|
- (void)recursivelyEnsureDisplay;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @abstract Allows a node to bypass all ensureDisplay passes. Defaults to NO.
|
||||||
|
*
|
||||||
|
* @discussion Nodes that are expensive to draw and expected to have placeholder even with
|
||||||
|
* .neverShowPlaceholders enabled should set this to YES.
|
||||||
|
*
|
||||||
|
* ASImageNode uses the default of NO, as it is often used for UI images that are expected to synchronize with ensureDisplay.
|
||||||
|
*
|
||||||
|
* ASNetworkImageNode and ASMultiplexImageNode set this to YES, because they load data from a database or server,
|
||||||
|
* and are expected to support a placeholder state given that display is often blocked on slow data fetching.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) BOOL shouldBypassEnsureDisplay;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#define ASDisplayNodeAssertThreadAffinity(viewNode) ASDisplayNodeAssert(!viewNode || ASDisplayNodeThreadIsMain() || !(viewNode).nodeLoaded, @"Incorrect display node thread affinity")
|
#define ASDisplayNodeAssertThreadAffinity(viewNode) ASDisplayNodeAssert(!viewNode || ASDisplayNodeThreadIsMain() || !(viewNode).nodeLoaded, @"Incorrect display node thread affinity")
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
#import <objc/runtime.h>
|
#import <objc/runtime.h>
|
||||||
|
|
||||||
#import "_ASAsyncTransaction.h"
|
#import "_ASAsyncTransaction.h"
|
||||||
|
#import "_ASAsyncTransactionContainer+Private.h"
|
||||||
#import "_ASPendingState.h"
|
#import "_ASPendingState.h"
|
||||||
#import "_ASDisplayView.h"
|
#import "_ASDisplayView.h"
|
||||||
#import "_ASScopeTimer.h"
|
#import "_ASScopeTimer.h"
|
||||||
@ -1415,6 +1416,68 @@ static NSInteger incrementIfFound(NSInteger i) {
|
|||||||
[_placeholderLayer removeFromSuperlayer];
|
[_placeholderLayer removeFromSuperlayer];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void recursivelyEnsureDisplayForLayer(CALayer *layer)
|
||||||
|
{
|
||||||
|
// This recursion must handle layers in various states:
|
||||||
|
// 1. Just added to hierarchy, CA hasn't yet called -display
|
||||||
|
// 2. Previously in a hierarchy (such as a working window owned by an Intelligent Preloading class, like ASTableView / ASCollectionView / ASViewController)
|
||||||
|
// 3. Has no content to display at all
|
||||||
|
// Specifically for case 1), we need to explicitly trigger a -display call now.
|
||||||
|
// Otherwise, there is no opportunity to block the main thread after CoreAnimation's transaction commit
|
||||||
|
// (even a runloop observer at a late call order will not stop the next frame from compositing, showing placeholders).
|
||||||
|
|
||||||
|
ASDisplayNode *node = [layer asyncdisplaykit_node];
|
||||||
|
if (!layer.contents && [node _implementsDisplay]) {
|
||||||
|
// For layers that do get displayed here, this immediately kicks off the work on the concurrent -[_ASDisplayLayer displayQueue].
|
||||||
|
// At the same time, it creates an associated _ASAsyncTransaction, which we can use to block on display completion. See ASDisplayNode+AsyncDisplay.mm.
|
||||||
|
[layer displayIfNeeded];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kick off the recursion first, so that all necessary display calls are sent and the displayQueue is full of parallelizable work.
|
||||||
|
for (CALayer *sublayer in layer.sublayers) {
|
||||||
|
recursivelyEnsureDisplayForLayer(sublayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// As the recursion unwinds, verify each transaction is complete and block if it is not.
|
||||||
|
// While blocking on one transaction, others may be completing concurrently, so it doesn't matter which blocks first.
|
||||||
|
BOOL waitUntilComplete = (!node.shouldBypassEnsureDisplay);
|
||||||
|
if (waitUntilComplete) {
|
||||||
|
for (_ASAsyncTransaction *transaction in [layer.asyncdisplaykit_asyncLayerTransactions copy]) {
|
||||||
|
// Even if none of the layers have had a chance to start display earlier, they will still be allowed to saturate a multicore CPU while blocking main.
|
||||||
|
// This significantly reduces time on the main thread relative to UIKit.
|
||||||
|
[transaction waitUntilComplete];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)recursivelyEnsureDisplay
|
||||||
|
{
|
||||||
|
ASDisplayNodeAssertMainThread();
|
||||||
|
ASDisplayNodeAssert(self.isNodeLoaded, @"Node must have layer or view loaded to use -recursivelyEnsureDisplay");
|
||||||
|
ASDisplayNodeAssert(self.inHierarchy && (self.isLayerBacked || self.view.window != nil), @"Node must be in a hierarchy to use -recursivelyEnsureDisplay");
|
||||||
|
|
||||||
|
CALayer *layer = self.layer;
|
||||||
|
// -layoutIfNeeded is recursive, and even walks up to superlayers to check if they need layout,
|
||||||
|
// so we should call it outside of starting the recursion below. If our own layer is not marked
|
||||||
|
// as dirty, we can assume layout has run on this subtree before.
|
||||||
|
if ([layer needsLayout]) {
|
||||||
|
[layer layoutIfNeeded];
|
||||||
|
}
|
||||||
|
recursivelyEnsureDisplayForLayer(layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setShouldBypassEnsureDisplay:(BOOL)shouldBypassEnsureDisplay
|
||||||
|
{
|
||||||
|
ASDN::MutexLocker l(_propertyLock);
|
||||||
|
_flags.shouldBypassEnsureDisplay = shouldBypassEnsureDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)shouldBypassEnsureDisplay
|
||||||
|
{
|
||||||
|
ASDN::MutexLocker l(_propertyLock);
|
||||||
|
return _flags.shouldBypassEnsureDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - For Subclasses
|
#pragma mark - For Subclasses
|
||||||
|
|
||||||
- (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize
|
- (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize
|
||||||
@ -1484,6 +1547,7 @@ static NSInteger incrementIfFound(NSInteger i) {
|
|||||||
ASDN::MutexLocker l(_propertyLock);
|
ASDN::MutexLocker l(_propertyLock);
|
||||||
return _preferredFrameSize;
|
return _preferredFrameSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UIImage *)placeholderImage
|
- (UIImage *)placeholderImage
|
||||||
{
|
{
|
||||||
return nil;
|
return nil;
|
||||||
|
|||||||
@ -158,6 +158,7 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
|
|||||||
|
|
||||||
_cache = cache;
|
_cache = cache;
|
||||||
_downloader = downloader;
|
_downloader = downloader;
|
||||||
|
self.shouldBypassEnsureDisplay = YES;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,6 +44,7 @@
|
|||||||
_cache = cache;
|
_cache = cache;
|
||||||
_downloader = downloader;
|
_downloader = downloader;
|
||||||
_shouldCacheImage = YES;
|
_shouldCacheImage = YES;
|
||||||
|
self.shouldBypassEnsureDisplay = YES;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,8 +27,28 @@
|
|||||||
*/
|
*/
|
||||||
@interface ASTableView : UITableView
|
@interface ASTableView : UITableView
|
||||||
|
|
||||||
@property (nonatomic, weak) id<ASTableViewDataSource> asyncDataSource;
|
|
||||||
@property (nonatomic, weak) id<ASTableViewDelegate> asyncDelegate; // must not be nil
|
@property (nonatomic, weak) id<ASTableViewDelegate> asyncDelegate; // must not be nil
|
||||||
|
@property (nonatomic, weak) id<ASTableViewDataSource> asyncDataSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializer.
|
||||||
|
*
|
||||||
|
* @param frame A rectangle specifying the initial location and size of the table view in its superview’s coordinates.
|
||||||
|
* The frame of the table view changes as table cells are added and deleted.
|
||||||
|
*
|
||||||
|
* @param style A constant that specifies the style of the table view. See UITableViewStyle for descriptions of valid constants.
|
||||||
|
*
|
||||||
|
* @param asyncDataFetchingEnabled This option is reserved for future use, and currently a no-op.
|
||||||
|
*
|
||||||
|
* @discussion If asyncDataFetching is enabled, the `ASTableView` will fetch data through `tableView:numberOfRowsInSection:` and
|
||||||
|
* `tableView:nodeForRowAtIndexPath:` in async mode from background thread. Otherwise, the methods will be invoked synchronically
|
||||||
|
* from calling thread.
|
||||||
|
* Enabling asyncDataFetching could avoid blocking main thread for `ASCellNode` allocation, which is frequently reported issue for
|
||||||
|
* large scale data. On another hand, the application code need take the responsibility to avoid data inconsistence. Specifically,
|
||||||
|
* we will lock the data source through `tableViewLockDataSource`, and unlock it by `tableViewUnlockDataSource` after the data fetching.
|
||||||
|
* The application should not update the data source while the data source is locked, to keep data consistence.
|
||||||
|
*/
|
||||||
|
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style asyncDataFetching:(BOOL)asyncDataFetchingEnabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tuning parameters for a range.
|
* Tuning parameters for a range.
|
||||||
@ -50,26 +70,6 @@
|
|||||||
*/
|
*/
|
||||||
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType;
|
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType;
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializer.
|
|
||||||
*
|
|
||||||
* @param frame A rectangle specifying the initial location and size of the table view in its superview’s coordinates.
|
|
||||||
* The frame of the table view changes as table cells are added and deleted.
|
|
||||||
*
|
|
||||||
* @param style A constant that specifies the style of the table view. See UITableViewStyle for descriptions of valid constants.
|
|
||||||
*
|
|
||||||
* @param asyncDataFetchingEnabled Enable the data fetching in async mode.
|
|
||||||
*
|
|
||||||
* @discussion If asyncDataFetching is enabled, the `ASTableView` will fetch data through `tableView:numberOfRowsInSection:` and
|
|
||||||
* `tableView:nodeForRowAtIndexPath:` in async mode from background thread. Otherwise, the methods will be invoked synchronically
|
|
||||||
* from calling thread.
|
|
||||||
* Enabling asyncDataFetching could avoid blocking main thread for `ASCellNode` allocation, which is frequently reported issue for
|
|
||||||
* large scale data. On another hand, the application code need take the responsibility to avoid data inconsistence. Specifically,
|
|
||||||
* we will lock the data source through `tableViewLockDataSource`, and unlock it by `tableViewUnlockDataSource` after the data fetching.
|
|
||||||
* The application should not update the data source while the data source is locked, to keep data consistence.
|
|
||||||
*/
|
|
||||||
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style asyncDataFetching:(BOOL)asyncDataFetchingEnabled;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of screens left to scroll before the delegate -tableView:beginBatchFetchingWithContext: is called.
|
* The number of screens left to scroll before the delegate -tableView:beginBatchFetchingWithContext: is called.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -18,6 +18,9 @@
|
|||||||
#import "ASInternalHelpers.h"
|
#import "ASInternalHelpers.h"
|
||||||
#import "ASLayout.h"
|
#import "ASLayout.h"
|
||||||
|
|
||||||
|
// FIXME: Temporary nonsense import until method names are finalized and exposed
|
||||||
|
#import "ASDisplayNode+Subclasses.h"
|
||||||
|
|
||||||
//#define LOG(...) NSLog(__VA_ARGS__)
|
//#define LOG(...) NSLog(__VA_ARGS__)
|
||||||
#define LOG(...)
|
#define LOG(...)
|
||||||
|
|
||||||
@ -569,6 +572,11 @@ void ASPerformBlockWithoutAnimation(BOOL withoutAnimation, void (^block)()) {
|
|||||||
if ([_asyncDelegate respondsToSelector:@selector(tableView:willDisplayNodeForRowAtIndexPath:)]) {
|
if ([_asyncDelegate respondsToSelector:@selector(tableView:willDisplayNodeForRowAtIndexPath:)]) {
|
||||||
[_asyncDelegate tableView:self willDisplayNodeForRowAtIndexPath:indexPath];
|
[_asyncDelegate tableView:self willDisplayNodeForRowAtIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASCellNode *cellNode = [self nodeForRowAtIndexPath:indexPath];
|
||||||
|
if (cellNode.neverShowPlaceholders) {
|
||||||
|
[cellNode recursivelyEnsureDisplay];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath*)indexPath
|
- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath*)indexPath
|
||||||
|
|||||||
@ -13,7 +13,11 @@
|
|||||||
|
|
||||||
@property (nonatomic, strong, readonly) ASDisplayNode *node;
|
@property (nonatomic, strong, readonly) ASDisplayNode *node;
|
||||||
|
|
||||||
//TODO Use nonnull annotation late on. Travis doesn't recognize it (yet).
|
// AsyncDisplayKit 2.0 BETA: This property is still being tested, but it allows
|
||||||
|
// blocking as a view controller becomes visible to ensure no placeholders flash onscreen.
|
||||||
|
// Refer to examples/SynchronousConcurrency, AsyncViewController.m
|
||||||
|
@property (nonatomic, assign) BOOL neverShowPlaceholders;
|
||||||
|
|
||||||
- (instancetype)initWithNode:(ASDisplayNode *)node;
|
- (instancetype)initWithNode:(ASDisplayNode *)node;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -10,7 +10,13 @@
|
|||||||
#import "ASAssert.h"
|
#import "ASAssert.h"
|
||||||
#import "ASDimension.h"
|
#import "ASDimension.h"
|
||||||
|
|
||||||
|
// FIXME: Temporary nonsense import until method names are finalized and exposed
|
||||||
|
#import "ASDisplayNode+Subclasses.h"
|
||||||
|
|
||||||
@implementation ASViewController
|
@implementation ASViewController
|
||||||
|
{
|
||||||
|
BOOL _ensureDisplayed;
|
||||||
|
}
|
||||||
|
|
||||||
- (instancetype)initWithNode:(ASDisplayNode *)node
|
- (instancetype)initWithNode:(ASDisplayNode *)node
|
||||||
{
|
{
|
||||||
@ -33,15 +39,25 @@
|
|||||||
|
|
||||||
- (void)viewWillLayoutSubviews
|
- (void)viewWillLayoutSubviews
|
||||||
{
|
{
|
||||||
|
[super viewWillLayoutSubviews];
|
||||||
CGSize viewSize = self.view.bounds.size;
|
CGSize viewSize = self.view.bounds.size;
|
||||||
ASSizeRange constrainedSize = ASSizeRangeMake(viewSize, viewSize);
|
ASSizeRange constrainedSize = ASSizeRangeMake(viewSize, viewSize);
|
||||||
[_node measureWithSizeRange:constrainedSize];
|
[_node measureWithSizeRange:constrainedSize];
|
||||||
[super viewWillLayoutSubviews];
|
}
|
||||||
|
|
||||||
|
- (void)viewDidLayoutSubviews
|
||||||
|
{
|
||||||
|
if (_ensureDisplayed && self.neverShowPlaceholders) {
|
||||||
|
_ensureDisplayed = NO;
|
||||||
|
[self.node recursivelyEnsureDisplay];
|
||||||
|
}
|
||||||
|
[super viewDidLayoutSubviews];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewWillAppear:(BOOL)animated
|
- (void)viewWillAppear:(BOOL)animated
|
||||||
{
|
{
|
||||||
[super viewWillAppear:animated];
|
[super viewWillAppear:animated];
|
||||||
|
_ensureDisplayed = YES;
|
||||||
[_node recursivelyFetchData];
|
[_node recursivelyFetchData];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,7 @@ typedef NS_ENUM(NSUInteger, ASAsyncTransactionState) {
|
|||||||
ASAsyncTransactionStateOpen = 0,
|
ASAsyncTransactionStateOpen = 0,
|
||||||
ASAsyncTransactionStateCommitted,
|
ASAsyncTransactionStateCommitted,
|
||||||
ASAsyncTransactionStateCanceled,
|
ASAsyncTransactionStateCanceled,
|
||||||
|
ASAsyncTransactionStateComplete
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,6 +55,13 @@ typedef NS_ENUM(NSUInteger, ASAsyncTransactionState) {
|
|||||||
- (id)initWithCallbackQueue:(dispatch_queue_t)callbackQueue
|
- (id)initWithCallbackQueue:(dispatch_queue_t)callbackQueue
|
||||||
completionBlock:(asyncdisplaykit_async_transaction_completion_block_t)completionBlock;
|
completionBlock:(asyncdisplaykit_async_transaction_completion_block_t)completionBlock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@summary Block the main thread until the transaction is complete, including callbacks.
|
||||||
|
|
||||||
|
@desc This must be called on the main thread.
|
||||||
|
*/
|
||||||
|
- (void)waitUntilComplete;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The dispatch queue that the completion blocks will be called on.
|
The dispatch queue that the completion blocks will be called on.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#import "_ASAsyncTransaction.h"
|
#import "_ASAsyncTransaction.h"
|
||||||
|
#import "_ASAsyncTransactionGroup.h"
|
||||||
#import "ASAssert.h"
|
#import "ASAssert.h"
|
||||||
|
|
||||||
@interface ASDisplayNodeAsyncTransactionOperation : NSObject
|
@interface ASDisplayNodeAsyncTransactionOperation : NSObject
|
||||||
@ -40,6 +40,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *)description
|
||||||
|
{
|
||||||
|
return [NSString stringWithFormat:@"<ASDisplayNodeAsyncTransactionOperation: %p - value = %@", self, self.value];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation _ASAsyncTransaction
|
@implementation _ASAsyncTransaction
|
||||||
@ -148,15 +153,56 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ASDisplayNodeAssert(_group != NULL, @"If there are operations, dispatch group should have been created");
|
ASDisplayNodeAssert(_group != NULL, @"If there are operations, dispatch group should have been created");
|
||||||
|
|
||||||
dispatch_group_notify(_group, _callbackQueue, ^{
|
dispatch_group_notify(_group, _callbackQueue, ^{
|
||||||
|
// _callbackQueue is the main queue in current practice (also asserted in -waitUntilComplete).
|
||||||
|
// This code should be reviewed before taking on significantly different use cases.
|
||||||
|
ASDisplayNodeAssertMainThread();
|
||||||
|
[self completeTransaction];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)completeTransaction
|
||||||
|
{
|
||||||
|
if (_state != ASAsyncTransactionStateComplete) {
|
||||||
BOOL isCanceled = (_state == ASAsyncTransactionStateCanceled);
|
BOOL isCanceled = (_state == ASAsyncTransactionStateCanceled);
|
||||||
for (ASDisplayNodeAsyncTransactionOperation *operation in _operations) {
|
for (ASDisplayNodeAsyncTransactionOperation *operation in _operations) {
|
||||||
[operation callAndReleaseCompletionBlock:isCanceled];
|
[operation callAndReleaseCompletionBlock:isCanceled];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Always set _state to Complete, even if we were cancelled, to block any extraneous
|
||||||
|
// calls to this method that may have been scheduled for the next runloop
|
||||||
|
// (e.g. if we needed to force one in this runloop with -waitUntilComplete, but another was already scheduled)
|
||||||
|
_state = ASAsyncTransactionStateComplete;
|
||||||
|
|
||||||
if (_completionBlock) {
|
if (_completionBlock) {
|
||||||
_completionBlock(self, isCanceled);
|
_completionBlock(self, isCanceled);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)waitUntilComplete
|
||||||
|
{
|
||||||
|
ASDisplayNodeAssertMainThread();
|
||||||
|
if (_state != ASAsyncTransactionStateComplete) {
|
||||||
|
if (_group) {
|
||||||
|
ASDisplayNodeAssertTrue(_callbackQueue == dispatch_get_main_queue());
|
||||||
|
dispatch_group_wait(_group, DISPATCH_TIME_FOREVER);
|
||||||
|
|
||||||
|
// At this point, the asynchronous operation may have completed, but the runloop
|
||||||
|
// observer has not committed the batch of transactions we belong to. It's important to
|
||||||
|
// commit ourselves via the group to avoid double-committing the transaction.
|
||||||
|
// This is only necessary when forcing display work to complete before allowing the runloop
|
||||||
|
// to continue, e.g. in the implementation of -[ASDisplayNode recursivelyEnsureDisplay].
|
||||||
|
if (_state == ASAsyncTransactionStateOpen) {
|
||||||
|
[_ASAsyncTransactionGroup commit];
|
||||||
|
ASDisplayNodeAssert(_state != ASAsyncTransactionStateOpen, @"Transaction should not be open after committing group");
|
||||||
|
}
|
||||||
|
// If we needed to commit the group above, -completeTransaction may have already been run.
|
||||||
|
// It is designed to accomodate this by checking _state to ensure it is not complete.
|
||||||
|
[self completeTransaction];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,4 +220,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *)description
|
||||||
|
{
|
||||||
|
return [NSString stringWithFormat:@"<_ASAsyncTransaction: %p - _state = %lu, _group = %@, _operations = %@>", self, (unsigned long)_state, _group, _operations];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
@interface _ASAsyncTransactionGroup : NSObject
|
@interface _ASAsyncTransactionGroup : NSObject
|
||||||
/// The main transaction group is scheduled to commit on every tick of the main runloop.
|
/// The main transaction group is scheduled to commit on every tick of the main runloop.
|
||||||
+ (instancetype)mainTransactionGroup;
|
+ (instancetype)mainTransactionGroup;
|
||||||
|
+ (void)commit;
|
||||||
|
|
||||||
/// Add a transaction container to be committed.
|
/// Add a transaction container to be committed.
|
||||||
/// @param containerLayer A layer containing a transaction to be commited. May or may not be a container layer.
|
/// @param containerLayer A layer containing a transaction to be commited. May or may not be a container layer.
|
||||||
|
|||||||
@ -95,6 +95,11 @@ static void _transactionGroupRunLoopObserverCallback(CFRunLoopObserverRef observ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (void)commit
|
||||||
|
{
|
||||||
|
[[_ASAsyncTransactionGroup mainTransactionGroup] commit];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
static void _transactionGroupRunLoopObserverCallback(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info)
|
static void _transactionGroupRunLoopObserverCallback(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info)
|
||||||
|
|||||||
@ -80,6 +80,7 @@ typedef NS_OPTIONS(NSUInteger, ASDisplayNodeMethodOverrides) {
|
|||||||
unsigned layerBacked:1;
|
unsigned layerBacked:1;
|
||||||
unsigned displaysAsynchronously:1;
|
unsigned displaysAsynchronously:1;
|
||||||
unsigned shouldRasterizeDescendants:1;
|
unsigned shouldRasterizeDescendants:1;
|
||||||
|
unsigned shouldBypassEnsureDisplay:1;
|
||||||
unsigned displaySuspended:1;
|
unsigned displaySuspended:1;
|
||||||
|
|
||||||
// whether custom drawing is enabled
|
// whether custom drawing is enabled
|
||||||
|
|||||||
BIN
examples/SynchronousConcurrency/Default-568h@2x.png
Normal file
BIN
examples/SynchronousConcurrency/Default-568h@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
BIN
examples/SynchronousConcurrency/Default-667h@2x.png
Normal file
BIN
examples/SynchronousConcurrency/Default-667h@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
BIN
examples/SynchronousConcurrency/Default-736h@3x.png
Normal file
BIN
examples/SynchronousConcurrency/Default-736h@3x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
3
examples/SynchronousConcurrency/Podfile
Normal file
3
examples/SynchronousConcurrency/Podfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
source 'https://github.com/CocoaPods/Specs.git'
|
||||||
|
platform :ios, '8.0'
|
||||||
|
pod 'AsyncDisplayKit', :path => '../..'
|
||||||
361
examples/SynchronousConcurrency/Sample.xcodeproj/project.pbxproj
Normal file
361
examples/SynchronousConcurrency/Sample.xcodeproj/project.pbxproj
Normal file
@ -0,0 +1,361 @@
|
|||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 46;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
0585428019D4DBE100606EA6 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 0585427F19D4DBE100606EA6 /* Default-568h@2x.png */; };
|
||||||
|
05E2128719D4DB510098F589 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E2128619D4DB510098F589 /* main.m */; };
|
||||||
|
05E2128A19D4DB510098F589 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E2128919D4DB510098F589 /* AppDelegate.m */; };
|
||||||
|
05E2128D19D4DB510098F589 /* AsyncTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E2128C19D4DB510098F589 /* AsyncTableViewController.m */; };
|
||||||
|
18748FDB1BB727B20053A9C1 /* AsyncViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18748FDA1BB727B20053A9C1 /* AsyncViewController.m */; settings = {ASSET_TAGS = (); }; };
|
||||||
|
18C2ED861B9B8CE700F627B3 /* RandomCoreGraphicsNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 18C2ED851B9B8CE700F627B3 /* RandomCoreGraphicsNode.m */; };
|
||||||
|
3EC0CDCBA10D483D9F386E5E /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D24B17D1E4A4E7A9566C5E9 /* libPods.a */; };
|
||||||
|
6C2C82AC19EE274300767484 /* Default-667h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C2C82AA19EE274300767484 /* Default-667h@2x.png */; };
|
||||||
|
6C2C82AD19EE274300767484 /* Default-736h@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C2C82AB19EE274300767484 /* Default-736h@3x.png */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
0585427F19D4DBE100606EA6 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../Default-568h@2x.png"; sourceTree = "<group>"; };
|
||||||
|
05E2128119D4DB510098F589 /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
05E2128519D4DB510098F589 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
05E2128619D4DB510098F589 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||||
|
05E2128819D4DB510098F589 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||||
|
05E2128919D4DB510098F589 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||||
|
05E2128B19D4DB510098F589 /* AsyncTableViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AsyncTableViewController.h; sourceTree = "<group>"; };
|
||||||
|
05E2128C19D4DB510098F589 /* AsyncTableViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AsyncTableViewController.m; sourceTree = "<group>"; };
|
||||||
|
088AA6578212BE9BFBB07B70 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
|
||||||
|
18748FD91BB727B20053A9C1 /* AsyncViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncViewController.h; sourceTree = "<group>"; };
|
||||||
|
18748FDA1BB727B20053A9C1 /* AsyncViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AsyncViewController.m; sourceTree = "<group>"; };
|
||||||
|
18C2ED841B9B8CE700F627B3 /* RandomCoreGraphicsNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RandomCoreGraphicsNode.h; sourceTree = "<group>"; };
|
||||||
|
18C2ED851B9B8CE700F627B3 /* RandomCoreGraphicsNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RandomCoreGraphicsNode.m; sourceTree = "<group>"; };
|
||||||
|
3D24B17D1E4A4E7A9566C5E9 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
6C2C82AA19EE274300767484 /* Default-667h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-667h@2x.png"; sourceTree = SOURCE_ROOT; };
|
||||||
|
6C2C82AB19EE274300767484 /* Default-736h@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-736h@3x.png"; sourceTree = SOURCE_ROOT; };
|
||||||
|
C068F1D3F0CC317E895FCDAB /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
05E2127E19D4DB510098F589 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
3EC0CDCBA10D483D9F386E5E /* libPods.a in Frameworks */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
05E2127819D4DB510098F589 = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
05E2128319D4DB510098F589 /* Sample */,
|
||||||
|
05E2128219D4DB510098F589 /* Products */,
|
||||||
|
1A943BF0259746F18D6E423F /* Frameworks */,
|
||||||
|
1AE410B73DA5C3BD087ACDD7 /* Pods */,
|
||||||
|
);
|
||||||
|
indentWidth = 2;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
tabWidth = 2;
|
||||||
|
usesTabs = 0;
|
||||||
|
};
|
||||||
|
05E2128219D4DB510098F589 /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
05E2128119D4DB510098F589 /* Sample.app */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
05E2128319D4DB510098F589 /* Sample */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
05E2128819D4DB510098F589 /* AppDelegate.h */,
|
||||||
|
05E2128919D4DB510098F589 /* AppDelegate.m */,
|
||||||
|
05E2128B19D4DB510098F589 /* AsyncTableViewController.h */,
|
||||||
|
05E2128C19D4DB510098F589 /* AsyncTableViewController.m */,
|
||||||
|
18748FD91BB727B20053A9C1 /* AsyncViewController.h */,
|
||||||
|
18748FDA1BB727B20053A9C1 /* AsyncViewController.m */,
|
||||||
|
18C2ED841B9B8CE700F627B3 /* RandomCoreGraphicsNode.h */,
|
||||||
|
18C2ED851B9B8CE700F627B3 /* RandomCoreGraphicsNode.m */,
|
||||||
|
05E2128419D4DB510098F589 /* Supporting Files */,
|
||||||
|
);
|
||||||
|
path = Sample;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
05E2128419D4DB510098F589 /* Supporting Files */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
0585427F19D4DBE100606EA6 /* Default-568h@2x.png */,
|
||||||
|
6C2C82AA19EE274300767484 /* Default-667h@2x.png */,
|
||||||
|
6C2C82AB19EE274300767484 /* Default-736h@3x.png */,
|
||||||
|
05E2128519D4DB510098F589 /* Info.plist */,
|
||||||
|
05E2128619D4DB510098F589 /* main.m */,
|
||||||
|
);
|
||||||
|
name = "Supporting Files";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
1A943BF0259746F18D6E423F /* Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
3D24B17D1E4A4E7A9566C5E9 /* libPods.a */,
|
||||||
|
);
|
||||||
|
name = Frameworks;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
1AE410B73DA5C3BD087ACDD7 /* Pods */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
C068F1D3F0CC317E895FCDAB /* Pods.debug.xcconfig */,
|
||||||
|
088AA6578212BE9BFBB07B70 /* Pods.release.xcconfig */,
|
||||||
|
);
|
||||||
|
name = Pods;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
05E2128019D4DB510098F589 /* Sample */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = 05E212A419D4DB510098F589 /* Build configuration list for PBXNativeTarget "Sample" */;
|
||||||
|
buildPhases = (
|
||||||
|
E080B80F89C34A25B3488E26 /* Check Pods Manifest.lock */,
|
||||||
|
05E2127D19D4DB510098F589 /* Sources */,
|
||||||
|
05E2127E19D4DB510098F589 /* Frameworks */,
|
||||||
|
05E2127F19D4DB510098F589 /* Resources */,
|
||||||
|
F012A6F39E0149F18F564F50 /* Copy Pods Resources */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = Sample;
|
||||||
|
productName = Sample;
|
||||||
|
productReference = 05E2128119D4DB510098F589 /* Sample.app */;
|
||||||
|
productType = "com.apple.product-type.application";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
05E2127919D4DB510098F589 /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
LastUpgradeCheck = 0600;
|
||||||
|
ORGANIZATIONNAME = Facebook;
|
||||||
|
TargetAttributes = {
|
||||||
|
05E2128019D4DB510098F589 = {
|
||||||
|
CreatedOnToolsVersion = 6.0.1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
buildConfigurationList = 05E2127C19D4DB510098F589 /* Build configuration list for PBXProject "Sample" */;
|
||||||
|
compatibilityVersion = "Xcode 3.2";
|
||||||
|
developmentRegion = English;
|
||||||
|
hasScannedForEncodings = 0;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
Base,
|
||||||
|
);
|
||||||
|
mainGroup = 05E2127819D4DB510098F589;
|
||||||
|
productRefGroup = 05E2128219D4DB510098F589 /* Products */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
05E2128019D4DB510098F589 /* Sample */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
|
05E2127F19D4DB510098F589 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
0585428019D4DBE100606EA6 /* Default-568h@2x.png in Resources */,
|
||||||
|
6C2C82AC19EE274300767484 /* Default-667h@2x.png in Resources */,
|
||||||
|
6C2C82AD19EE274300767484 /* Default-736h@3x.png in Resources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXShellScriptBuildPhase section */
|
||||||
|
E080B80F89C34A25B3488E26 /* Check Pods Manifest.lock */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
|
name = "Check Pods Manifest.lock";
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
|
||||||
|
showEnvVarsInLog = 0;
|
||||||
|
};
|
||||||
|
F012A6F39E0149F18F564F50 /* Copy Pods Resources */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
|
name = "Copy Pods Resources";
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n";
|
||||||
|
showEnvVarsInLog = 0;
|
||||||
|
};
|
||||||
|
/* End PBXShellScriptBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
05E2127D19D4DB510098F589 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
18C2ED861B9B8CE700F627B3 /* RandomCoreGraphicsNode.m in Sources */,
|
||||||
|
18748FDB1BB727B20053A9C1 /* AsyncViewController.m in Sources */,
|
||||||
|
05E2128D19D4DB510098F589 /* AsyncTableViewController.m in Sources */,
|
||||||
|
05E2128A19D4DB510098F589 /* AppDelegate.m in Sources */,
|
||||||
|
05E2128719D4DB510098F589 /* main.m in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
05E212A219D4DB510098F589 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = YES;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
05E212A319D4DB510098F589 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||||
|
COPY_PHASE_STRIP = YES;
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
VALIDATE_PRODUCT = YES;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
05E212A519D4DB510098F589 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = C068F1D3F0CC317E895FCDAB /* Pods.debug.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
INFOPLIST_FILE = Sample/Info.plist;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
05E212A619D4DB510098F589 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 088AA6578212BE9BFBB07B70 /* Pods.release.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
INFOPLIST_FILE = Sample/Info.plist;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
05E2127C19D4DB510098F589 /* Build configuration list for PBXProject "Sample" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
05E212A219D4DB510098F589 /* Debug */,
|
||||||
|
05E212A319D4DB510098F589 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
05E212A419D4DB510098F589 /* Build configuration list for PBXNativeTarget "Sample" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
05E212A519D4DB510098F589 /* Debug */,
|
||||||
|
05E212A619D4DB510098F589 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = 05E2127919D4DB510098F589 /* Project object */;
|
||||||
|
}
|
||||||
7
examples/SynchronousConcurrency/Sample.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
examples/SynchronousConcurrency/Sample.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "self:Sample.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
||||||
@ -0,0 +1,88 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "0620"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "05E2128019D4DB510098F589"
|
||||||
|
BuildableName = "Sample.app"
|
||||||
|
BlueprintName = "Sample"
|
||||||
|
ReferencedContainer = "container:Sample.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
<Testables>
|
||||||
|
</Testables>
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "05E2128019D4DB510098F589"
|
||||||
|
BuildableName = "Sample.app"
|
||||||
|
BlueprintName = "Sample"
|
||||||
|
ReferencedContainer = "container:Sample.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "05E2128019D4DB510098F589"
|
||||||
|
BuildableName = "Sample.app"
|
||||||
|
BlueprintName = "Sample"
|
||||||
|
ReferencedContainer = "container:Sample.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "05E2128019D4DB510098F589"
|
||||||
|
BuildableName = "Sample.app"
|
||||||
|
BlueprintName = "Sample"
|
||||||
|
ReferencedContainer = "container:Sample.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
1
examples/SynchronousConcurrency/Sample.xcworkspace/contents.xcworkspacedata
generated
Normal file
1
examples/SynchronousConcurrency/Sample.xcworkspace/contents.xcworkspacedata
generated
Normal file
@ -0,0 +1 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?><Workspace version='1.0'><FileRef location='group:Sample.xcodeproj'/><FileRef location='group:Pods/Pods.xcodeproj'/></Workspace>
|
||||||
20
examples/SynchronousConcurrency/Sample/AppDelegate.h
Normal file
20
examples/SynchronousConcurrency/Sample/AppDelegate.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/* This file provided by Facebook is for non-commercial testing and evaluation
|
||||||
|
* purposes only. Facebook reserves all rights not expressly granted.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#define UseAutomaticLayout 1
|
||||||
|
|
||||||
|
@interface AppDelegate : UIResponder <UIApplicationDelegate>
|
||||||
|
|
||||||
|
@property (strong, nonatomic) UIWindow *window;
|
||||||
|
|
||||||
|
@end
|
||||||
33
examples/SynchronousConcurrency/Sample/AppDelegate.m
Normal file
33
examples/SynchronousConcurrency/Sample/AppDelegate.m
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/* This file provided by Facebook is for non-commercial testing and evaluation
|
||||||
|
* purposes only. Facebook reserves all rights not expressly granted.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "AppDelegate.h"
|
||||||
|
|
||||||
|
#import "AsyncTableViewController.h"
|
||||||
|
#import "AsyncViewController.h"
|
||||||
|
|
||||||
|
@implementation AppDelegate
|
||||||
|
|
||||||
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||||
|
{
|
||||||
|
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||||
|
self.window.backgroundColor = [UIColor whiteColor];
|
||||||
|
|
||||||
|
UITabBarController *tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
|
||||||
|
self.window.rootViewController = tabBarController;
|
||||||
|
|
||||||
|
[tabBarController setViewControllers:@[[[AsyncTableViewController alloc] init], [[AsyncViewController alloc] init]]];
|
||||||
|
|
||||||
|
[self.window makeKeyAndVisible];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
/* This file provided by Facebook is for non-commercial testing and evaluation
|
||||||
|
* purposes only. Facebook reserves all rights not expressly granted.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
@interface AsyncTableViewController : UIViewController
|
||||||
|
|
||||||
|
@end
|
||||||
@ -0,0 +1,91 @@
|
|||||||
|
/* This file provided by Facebook is for non-commercial testing and evaluation
|
||||||
|
* purposes only. Facebook reserves all rights not expressly granted.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <AsyncDisplayKit/AsyncDisplayKit.h>
|
||||||
|
#import <AsyncDisplayKit/ASAssert.h>
|
||||||
|
|
||||||
|
#import "AsyncTableViewController.h"
|
||||||
|
#import "RandomCoreGraphicsNode.h"
|
||||||
|
|
||||||
|
@interface AsyncTableViewController () <ASTableViewDataSource, ASTableViewDelegate>
|
||||||
|
{
|
||||||
|
ASTableView *_tableView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation AsyncTableViewController
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark UIViewController.
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
if (!(self = [super init]))
|
||||||
|
return nil;
|
||||||
|
|
||||||
|
_tableView = [[ASTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||||||
|
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||||
|
_tableView.asyncDataSource = self;
|
||||||
|
_tableView.asyncDelegate = self;
|
||||||
|
|
||||||
|
ASRangeTuningParameters tuningParameters;
|
||||||
|
tuningParameters.leadingBufferScreenfuls = 0.5;
|
||||||
|
tuningParameters.trailingBufferScreenfuls = 1.0;
|
||||||
|
[_tableView setTuningParameters:tuningParameters forRangeType:ASLayoutRangeTypePreload];
|
||||||
|
[_tableView setTuningParameters:tuningParameters forRangeType:ASLayoutRangeTypeRender];
|
||||||
|
|
||||||
|
self.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFeatured tag:0];
|
||||||
|
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRedo
|
||||||
|
target:self
|
||||||
|
action:@selector(reloadEverything)];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)reloadEverything
|
||||||
|
{
|
||||||
|
[_tableView reloadData];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)viewDidLoad
|
||||||
|
{
|
||||||
|
[super viewDidLoad];
|
||||||
|
|
||||||
|
[self.view addSubview:_tableView];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)viewWillLayoutSubviews
|
||||||
|
{
|
||||||
|
_tableView.frame = self.view.bounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)prefersStatusBarHidden
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark ASTableView.
|
||||||
|
|
||||||
|
- (ASCellNode *)tableView:(ASTableView *)tableView nodeForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
|
{
|
||||||
|
RandomCoreGraphicsNode *elementNode = [[RandomCoreGraphicsNode alloc] init];
|
||||||
|
elementNode.preferredFrameSize = CGSizeMake(320, 100);
|
||||||
|
return elementNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||||
|
{
|
||||||
|
return 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
13
examples/SynchronousConcurrency/Sample/AsyncViewController.h
Normal file
13
examples/SynchronousConcurrency/Sample/AsyncViewController.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
//
|
||||||
|
// AsyncViewController.h
|
||||||
|
// Sample
|
||||||
|
//
|
||||||
|
// Created by Scott Goodson on 9/26/15.
|
||||||
|
// Copyright © 2015 Facebook. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "ASViewController.h"
|
||||||
|
|
||||||
|
@interface AsyncViewController : ASViewController <UITabBarControllerDelegate>
|
||||||
|
|
||||||
|
@end
|
||||||
37
examples/SynchronousConcurrency/Sample/AsyncViewController.m
Normal file
37
examples/SynchronousConcurrency/Sample/AsyncViewController.m
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
//
|
||||||
|
// AsyncViewController.m
|
||||||
|
// Sample
|
||||||
|
//
|
||||||
|
// Created by Scott Goodson on 9/26/15.
|
||||||
|
// Copyright © 2015 Facebook. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "AsyncViewController.h"
|
||||||
|
#import "RandomCoreGraphicsNode.h"
|
||||||
|
|
||||||
|
@implementation AsyncViewController
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
if (!(self = [super initWithNode:[[RandomCoreGraphicsNode alloc] init]])) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.neverShowPlaceholders = YES;
|
||||||
|
self.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:0];
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)viewWillAppear:(BOOL)animated
|
||||||
|
{
|
||||||
|
// FIXME: This is only being called on the first time the UITabBarController shows us.
|
||||||
|
[super viewWillAppear:animated];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)viewDidDisappear:(BOOL)animated
|
||||||
|
{
|
||||||
|
[self.node recursivelyClearContents];
|
||||||
|
[super viewDidDisappear:animated];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
36
examples/SynchronousConcurrency/Sample/Info.plist
Normal file
36
examples/SynchronousConcurrency/Sample/Info.plist
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>en</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.facebook.AsyncDisplayKit.$(PRODUCT_NAME:rfc1034identifier)</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>$(PRODUCT_NAME)</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
<true/>
|
||||||
|
<key>UIRequiredDeviceCapabilities</key>
|
||||||
|
<array>
|
||||||
|
<string>armv7</string>
|
||||||
|
</array>
|
||||||
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// RandomCoreGraphicsNode.h
|
||||||
|
// Sample
|
||||||
|
//
|
||||||
|
// Created by Scott Goodson on 9/5/15.
|
||||||
|
// Copyright (c) 2015 Facebook. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <AsyncDisplayKit/AsyncDisplayKit.h>
|
||||||
|
|
||||||
|
@interface RandomCoreGraphicsNode : ASCellNode
|
||||||
|
{
|
||||||
|
ASTextNode *_textNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@ -0,0 +1,93 @@
|
|||||||
|
//
|
||||||
|
// RandomCoreGraphicsNode.m
|
||||||
|
// Sample
|
||||||
|
//
|
||||||
|
// Created by Scott Goodson on 9/5/15.
|
||||||
|
// Copyright (c) 2015 Facebook. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "RandomCoreGraphicsNode.h"
|
||||||
|
#import <AsyncDisplayKit/ASDisplayNode+Subclasses.h>
|
||||||
|
|
||||||
|
@implementation RandomCoreGraphicsNode
|
||||||
|
|
||||||
|
+ (UIColor *)randomColor
|
||||||
|
{
|
||||||
|
CGFloat hue = ( arc4random() % 256 / 256.0 ); // 0.0 to 1.0
|
||||||
|
CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from white
|
||||||
|
CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from black
|
||||||
|
return [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)drawRect:(CGRect)bounds withParameters:(id<NSObject>)parameters isCancelled:(asdisplaynode_iscancelled_block_t)isCancelledBlock isRasterizing:(BOOL)isRasterizing
|
||||||
|
{
|
||||||
|
CGFloat locations[3];
|
||||||
|
NSMutableArray *colors = [NSMutableArray arrayWithCapacity:3];
|
||||||
|
[colors addObject:(id)[[RandomCoreGraphicsNode randomColor] CGColor]];
|
||||||
|
locations[0] = 0.0;
|
||||||
|
[colors addObject:(id)[[RandomCoreGraphicsNode randomColor] CGColor]];
|
||||||
|
locations[1] = 1.0;
|
||||||
|
[colors addObject:(id)[[RandomCoreGraphicsNode randomColor] CGColor]];
|
||||||
|
locations[2] = ( arc4random() % 256 / 256.0 );
|
||||||
|
|
||||||
|
|
||||||
|
CGContextRef ctx = UIGraphicsGetCurrentContext();
|
||||||
|
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||||
|
CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (CFArrayRef)colors, locations);
|
||||||
|
|
||||||
|
CGGradientDrawingOptions drawingOptions;
|
||||||
|
CGContextDrawLinearGradient(ctx, gradient, CGPointZero, CGPointMake(bounds.size.width, bounds.size.height), drawingOptions);
|
||||||
|
|
||||||
|
CGColorSpaceRelease(colorSpace);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSObject *)drawParametersForAsyncLayer:(_ASDisplayLayer *)layer
|
||||||
|
{
|
||||||
|
return [self description];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *)textStyle
|
||||||
|
{
|
||||||
|
UIFont *font = [UIFont fontWithName:@"HelveticaNeue" size:36.0f];
|
||||||
|
|
||||||
|
NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||||
|
style.paragraphSpacing = 0.5 * font.lineHeight;
|
||||||
|
style.hyphenationFactor = 1.0;
|
||||||
|
|
||||||
|
return @{ NSFontAttributeName: font,
|
||||||
|
NSParagraphStyleAttributeName: style };
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
if (!(self = [super init])) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
_textNode = [[ASTextNode alloc] init];
|
||||||
|
_textNode.placeholderEnabled = NO;
|
||||||
|
_textNode.attributedString = [[NSAttributedString alloc] initWithString:@"Hello, ASDK!"
|
||||||
|
attributes:[self textStyle]];
|
||||||
|
[self addSubnode:_textNode];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CGSize)calculateSizeThatFits:(CGSize)constrainedSize
|
||||||
|
{
|
||||||
|
[_textNode measure:constrainedSize];
|
||||||
|
return CGSizeMake(constrainedSize.width, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)layout
|
||||||
|
{
|
||||||
|
CGSize boundsSize = self.bounds.size;
|
||||||
|
CGSize textSize = _textNode.calculatedSize;
|
||||||
|
CGRect textRect = CGRectMake(roundf((boundsSize.width - textSize.width) / 2.0),
|
||||||
|
roundf((boundsSize.height - textSize.height) / 2.0),
|
||||||
|
textSize.width,
|
||||||
|
textSize.height);
|
||||||
|
_textNode.frame = textRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
20
examples/SynchronousConcurrency/Sample/main.m
Normal file
20
examples/SynchronousConcurrency/Sample/main.m
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/* This file provided by Facebook is for non-commercial testing and evaluation
|
||||||
|
* purposes only. Facebook reserves all rights not expressly granted.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#import "AppDelegate.h"
|
||||||
|
|
||||||
|
int main(int argc, char * argv[]) {
|
||||||
|
@autoreleasepool {
|
||||||
|
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user