Swiftgram/AsyncDisplayKit/Details/ASBatchContext.mm
Hannah Troisi c857e809f4 Clean up header comments (for consistent Facebook licensing info) (#1741)
[Licensing] Clean up header comments (for consistent Facebook licensing info)
2016-06-11 23:31:39 -07:00

71 lines
1.4 KiB
Plaintext

//
// ASBatchContext.mm
// 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 "ASBatchContext.h"
#import "ASThread.h"
typedef NS_ENUM(NSInteger, ASBatchContextState) {
ASBatchContextStateFetching,
ASBatchContextStateCancelled,
ASBatchContextStateCompleted
};
@interface ASBatchContext ()
{
ASBatchContextState _state;
ASDN::RecursiveMutex _propertyLock;
}
@end
@implementation ASBatchContext
- (instancetype)init
{
if (self = [super init]) {
_state = ASBatchContextStateCompleted;
}
return self;
}
- (BOOL)isFetching
{
ASDN::MutexLocker l(_propertyLock);
return _state == ASBatchContextStateFetching;
}
- (BOOL)batchFetchingWasCancelled
{
ASDN::MutexLocker l(_propertyLock);
return _state == ASBatchContextStateCancelled;
}
- (void)beginBatchFetching
{
ASDN::MutexLocker l(_propertyLock);
_state = ASBatchContextStateFetching;
}
- (void)completeBatchFetching:(BOOL)didComplete
{
if (didComplete) {
ASDN::MutexLocker l(_propertyLock);
_state = ASBatchContextStateCompleted;
}
}
- (void)cancelBatchFetching
{
ASDN::MutexLocker l(_propertyLock);
_state = ASBatchContextStateCancelled;
}
@end