From 0115ae02284b86beea65db3ebc20f1bbb4ad7566 Mon Sep 17 00:00:00 2001 From: Lawrence Lomax Date: Wed, 6 Dec 2017 06:01:04 -0800 Subject: [PATCH] Remove FBTerminationHandle Summary: As we've now finally got rid if the need for this abstraction, we can remove it entirely. Reviewed By: dtorres, marekcirkos Differential Revision: D6468396 fbshipit-source-id: 2239b89b755e3958d8c778319e93016907ccfc20 --- FBControlCore/Actions/FBiOSActionReader.h | 1 - FBControlCore/Async/FBTerminationHandle.h | 38 ------------------- FBControlCore/Commands/FBXCTestCommands.h | 5 +-- FBControlCore/FBControlCore.h | 1 - FBControlCore/Tasks/FBTask.h | 13 +++---- FBControlCore/Tasks/FBTask.m | 20 +++------- .../Utility/FBDispatchSourceNotifier.h | 20 ++++++---- .../Utility/FBDispatchSourceNotifier.m | 11 ++---- FBSimulatorControl.xcodeproj/project.pbxproj | 4 -- .../Notifiers/FBCoreSimulatorNotifier.h | 20 +++++----- .../Notifiers/FBCoreSimulatorNotifier.m | 7 ---- 11 files changed, 41 insertions(+), 99 deletions(-) delete mode 100644 FBControlCore/Async/FBTerminationHandle.h diff --git a/FBControlCore/Actions/FBiOSActionReader.h b/FBControlCore/Actions/FBiOSActionReader.h index 6f73112a..224f230c 100644 --- a/FBControlCore/Actions/FBiOSActionReader.h +++ b/FBControlCore/Actions/FBiOSActionReader.h @@ -12,7 +12,6 @@ #import #import #import -#import NS_ASSUME_NONNULL_BEGIN diff --git a/FBControlCore/Async/FBTerminationHandle.h b/FBControlCore/Async/FBTerminationHandle.h deleted file mode 100644 index 36e7f00c..00000000 --- a/FBControlCore/Async/FBTerminationHandle.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2015-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 - -#import - -NS_ASSUME_NONNULL_BEGIN - -/** - Extensible Diagnostic Name Enumeration. - */ -typedef NSString *FBTerminationHandleType NS_EXTENSIBLE_STRING_ENUM; - -/** - Simple protocol that allows asynchronous operations to be terminated. - */ -@protocol FBTerminationHandle - -/** - Terminates the asynchronous operation. - */ -- (void)terminate; - -/** - The Type of Termination Handle. - */ -@property (nonatomic, copy, readonly) FBTerminationHandleType handleType; - -@end - -NS_ASSUME_NONNULL_END diff --git a/FBControlCore/Commands/FBXCTestCommands.h b/FBControlCore/Commands/FBXCTestCommands.h index 030e7565..e44c5191 100644 --- a/FBControlCore/Commands/FBXCTestCommands.h +++ b/FBControlCore/Commands/FBXCTestCommands.h @@ -11,10 +11,10 @@ #import #import -#import NS_ASSUME_NONNULL_BEGIN +@class FBTestLaunchConfiguration; @protocol FBControlCoreLogger; @protocol FBTestManagerTestReporter; @@ -23,8 +23,6 @@ NS_ASSUME_NONNULL_BEGIN */ extern FBiOSTargetFutureType const FBiOSTargetFutureTypeTestOperation; -@class FBTestLaunchConfiguration; - /** Commands to perform on an iOS Target, related to XCTest. */ @@ -40,6 +38,7 @@ extern FBiOSTargetFutureType const FBiOSTargetFutureTypeTestOperation; @return a Future, wrapping a test operation. */ - (FBFuture> *)startTestWithLaunchConfiguration:(FBTestLaunchConfiguration *)testLaunchConfiguration reporter:(nullable id)reporter logger:(id)logger; + /** Lists the testables for a provided test bundle. diff --git a/FBControlCore/FBControlCore.h b/FBControlCore/FBControlCore.h index 9259b4c7..328703e1 100644 --- a/FBControlCore/FBControlCore.h +++ b/FBControlCore/FBControlCore.h @@ -74,7 +74,6 @@ #import #import #import -#import #import #import #import diff --git a/FBControlCore/Tasks/FBTask.h b/FBControlCore/Tasks/FBTask.h index af36fe46..ff953dda 100644 --- a/FBControlCore/Tasks/FBTask.h +++ b/FBControlCore/Tasks/FBTask.h @@ -9,7 +9,6 @@ #import -#import #import NS_ASSUME_NONNULL_BEGIN @@ -22,15 +21,10 @@ NS_ASSUME_NONNULL_BEGIN */ extern NSString *const FBTaskErrorDomain; -/** - The Termination Handle Type for a Task. - */ -extern FBTerminationHandleType const FBTerminationHandleTypeTask; - /** Programmatic interface to a Task. */ -@interface FBTask : NSObject +@interface FBTask : NSObject #pragma mark Initializers @@ -117,6 +111,11 @@ extern FBTerminationHandleType const FBTerminationHandleTypeTask; */ - (nullable NSError *)error; +/** + Cancels the Task. + */ +- (void)terminate; + /** Returns YES if the task has terminated, NO otherwise. */ diff --git a/FBControlCore/Tasks/FBTask.m b/FBControlCore/Tasks/FBTask.m index 33dd88ab..c26999fe 100644 --- a/FBControlCore/Tasks/FBTask.m +++ b/FBControlCore/Tasks/FBTask.m @@ -21,7 +21,6 @@ #pragma clang diagnostic ignored "-Warc-retain-cycles" NSString *const FBTaskErrorDomain = @"com.facebook.FBControlCore.task"; -FBTerminationHandleType const FBTerminationHandleTypeTask = @"Task"; @protocol FBTaskOutput @@ -424,19 +423,7 @@ FBTerminationHandleType const FBTerminationHandleTypeTask = @"Task"; return self; } -#pragma mark - FBTerminationHandle Protocol - -- (void)terminate -{ - [self terminateWithErrorMessage:nil]; -} - -- (FBTerminationHandleType)handleType -{ - return FBTerminationHandleTypeTask; -} - -#pragma mark - FBTask Protocl +#pragma mark - FBTask Protocol #pragma mark Starting @@ -516,6 +503,11 @@ FBTerminationHandleType const FBTerminationHandleTypeTask = @"Task"; return [error build]; } +- (void)terminate +{ + [self terminateWithErrorMessage:nil]; +} + - (BOOL)hasTerminated { return self.completedTeardown; diff --git a/FBControlCore/Utility/FBDispatchSourceNotifier.h b/FBControlCore/Utility/FBDispatchSourceNotifier.h index bbe66971..d5396fa7 100644 --- a/FBControlCore/Utility/FBDispatchSourceNotifier.h +++ b/FBControlCore/Utility/FBDispatchSourceNotifier.h @@ -9,19 +9,14 @@ #import -#import - NS_ASSUME_NONNULL_BEGIN -/** - The Termination Handle type for a Dispatch Source. - */ -extern FBTerminationHandleType const FBTerminationHandleTypeDispatchSource; - /** A class for wrapping `dispatch_source` with some conveniences. */ -@interface FBDispatchSourceNotifier : NSObject +@interface FBDispatchSourceNotifier : NSObject + +#pragma mark Constructors /** Creates and returns an `FBDispatchSourceNotifier` that will call the `handler` when the provided `processIdentifier` quits @@ -41,6 +36,15 @@ extern FBTerminationHandleType const FBTerminationHandleTypeDispatchSource; */ + (instancetype)timerNotifierNotifierWithTimeInterval:(uint64_t)timeInterval queue:(dispatch_queue_t)queue handler:(void (^)(FBDispatchSourceNotifier *))handler; +#pragma mark Public Methods + +/** + Stops the Notifier. + */ +- (void)terminate; + +#pragma mark Properties + /** The Wrapped Dispatch Source. */ diff --git a/FBControlCore/Utility/FBDispatchSourceNotifier.m b/FBControlCore/Utility/FBDispatchSourceNotifier.m index e9b71417..d4571e95 100644 --- a/FBControlCore/Utility/FBDispatchSourceNotifier.m +++ b/FBControlCore/Utility/FBDispatchSourceNotifier.m @@ -9,10 +9,10 @@ #import "FBDispatchSourceNotifier.h" -FBTerminationHandleType const FBTerminationHandleTypeDispatchSource = @"DispatchSource"; - @implementation FBDispatchSourceNotifier +#pragma mark Initializers + + (instancetype)processTerminationNotifierForProcessIdentifier:(pid_t)processIdentifier queue:(dispatch_queue_t)queue handler:(void (^)(FBDispatchSourceNotifier *))handler { dispatch_source_t dispatchSource = dispatch_source_create( @@ -53,6 +53,8 @@ FBTerminationHandleType const FBTerminationHandleTypeDispatchSource = @"Dispatch return self; } +#pragma mark Public + - (void)terminate { if (self.dispatchSource) { @@ -61,11 +63,6 @@ FBTerminationHandleType const FBTerminationHandleTypeDispatchSource = @"Dispatch } } -- (FBTerminationHandleType)handleType -{ - return FBTerminationHandleTypeDispatchSource; -} - - (void)dealloc { [self terminate]; diff --git a/FBSimulatorControl.xcodeproj/project.pbxproj b/FBSimulatorControl.xcodeproj/project.pbxproj index 8cf2698b..ec187a05 100644 --- a/FBSimulatorControl.xcodeproj/project.pbxproj +++ b/FBSimulatorControl.xcodeproj/project.pbxproj @@ -259,7 +259,6 @@ AA719E4A1D672D6300947611 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AAC8B2621CEC55370034A865 /* Foundation.framework */; }; AA71A1171FA8E49D00BB10DA /* FBControlCoreRunLoopTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AA71A1161FA8E49D00BB10DA /* FBControlCoreRunLoopTests.m */; }; AA7219F41D82973E002668BF /* FBSimulatorConfigurationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AA7219F31D82973E002668BF /* FBSimulatorConfigurationTests.m */; }; - AA722D981F588022000FB6D3 /* FBTerminationHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = AA722D961F58801A000FB6D3 /* FBTerminationHandle.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7414F01CE3102F00C9641D /* FBTestBundleConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7414EE1CE3102F00C9641D /* FBTestBundleConnection.h */; }; AA7414F11CE3102F00C9641D /* FBTestBundleConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = AA7414EF1CE3102F00C9641D /* FBTestBundleConnection.m */; }; AA7728AE1E5238A6008FCF7C /* FBFileWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7728AC1E5238A6008FCF7C /* FBFileWriter.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1179,7 +1178,6 @@ AA6F98EA1D2B9C8E00464B0F /* FBBinaryDescriptor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBBinaryDescriptor.m; sourceTree = ""; }; AA71A1161FA8E49D00BB10DA /* FBControlCoreRunLoopTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBControlCoreRunLoopTests.m; sourceTree = ""; }; AA7219F31D82973E002668BF /* FBSimulatorConfigurationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBSimulatorConfigurationTests.m; sourceTree = ""; }; - AA722D961F58801A000FB6D3 /* FBTerminationHandle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBTerminationHandle.h; sourceTree = ""; }; AA7414EE1CE3102F00C9641D /* FBTestBundleConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBTestBundleConnection.h; sourceTree = ""; }; AA7414EF1CE3102F00C9641D /* FBTestBundleConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBTestBundleConnection.m; sourceTree = ""; }; AA7728AC1E5238A6008FCF7C /* FBFileWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBFileWriter.h; sourceTree = ""; }; @@ -1718,7 +1716,6 @@ children = ( AA0848791F3F499800A4BA60 /* FBFuture.h */, AA08487A1F3F499800A4BA60 /* FBFuture.m */, - AA722D961F58801A000FB6D3 /* FBTerminationHandle.h */, AAD0FA161FA1CA9200EBCEA8 /* NSRunLoop+FBControlCore.h */, AAD0FA151FA1CA9200EBCEA8 /* NSRunLoop+FBControlCore.m */, ); @@ -3427,7 +3424,6 @@ AABBF32B1DAC112900E2B6AF /* FBTaskConfiguration.h in Headers */, EE2EC7AC1CAC3F97009A7BB1 /* FBWeakFramework.h in Headers */, AAEA9C251DB4EB16009642CB /* FBDiagnosticQuery.h in Headers */, - AA722D981F588022000FB6D3 /* FBTerminationHandle.h in Headers */, EEBD606A1C9062E900298A07 /* FBDebugDescribeable.h in Headers */, D76F950D1F56D6700003D341 /* FBTestLaunchConfiguration.h in Headers */, D76F95091F56D65C0003D341 /* FBXCTestCommands.h in Headers */, diff --git a/FBSimulatorControl/Notifiers/FBCoreSimulatorNotifier.h b/FBSimulatorControl/Notifiers/FBCoreSimulatorNotifier.h index f228fb68..449f624e 100644 --- a/FBSimulatorControl/Notifiers/FBCoreSimulatorNotifier.h +++ b/FBSimulatorControl/Notifiers/FBCoreSimulatorNotifier.h @@ -9,23 +9,18 @@ #import -#import +NS_ASSUME_NONNULL_BEGIN @class FBSimulator; @class FBSimulatorSet; @class SimDevice; -NS_ASSUME_NONNULL_BEGIN - /** - The Termination Handle Type. + A Notifies of Lifecycle events in CoreSimulator. */ -extern FBTerminationHandleType const FBTerminationHandleTypeCoreSimulatorNotifier; +@interface FBCoreSimulatorNotifier : NSObject -/** - A class for wrapping Core Simulator Notifiers in a `FBTerminationHandle` - */ -@interface FBCoreSimulatorNotifier : NSObject +#pragma mark Initializers /** Creates and returns an FBSimDeviceNotifier for the lifecycle events that SimDevice broadcasts. @@ -47,6 +42,13 @@ extern FBTerminationHandleType const FBTerminationHandleTypeCoreSimulatorNotifie */ + (instancetype)notifierForSet:(FBSimulatorSet *)set queue:(dispatch_queue_t)queue block:(void (^)(NSDictionary *info))block; +#pragma mark Public Methods + +/** + Terminates the Notifier. + */ +- (void)terminate; + @end NS_ASSUME_NONNULL_END diff --git a/FBSimulatorControl/Notifiers/FBCoreSimulatorNotifier.m b/FBSimulatorControl/Notifiers/FBCoreSimulatorNotifier.m index 61700668..5363cb29 100644 --- a/FBSimulatorControl/Notifiers/FBCoreSimulatorNotifier.m +++ b/FBSimulatorControl/Notifiers/FBCoreSimulatorNotifier.m @@ -17,8 +17,6 @@ #import "FBSimulator.h" #import "FBSimulatorSet.h" -FBTerminationHandleType const FBTerminationHandleTypeCoreSimulatorNotifier = @"CoreSimulatorNotifier"; - @interface FBCoreSimulatorNotifier () @property (nonatomic, readonly, assign) unsigned long long handle; @@ -62,9 +60,4 @@ FBTerminationHandleType const FBTerminationHandleTypeCoreSimulatorNotifier = @"C [self.notifier unregisterNotificationHandler:self.handle error:nil]; } -- (FBTerminationHandleType)handleType -{ - return FBTerminationHandleTypeCoreSimulatorNotifier; -} - @end