New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor ResultInjection - again #541
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Merged
danthorpe
added a commit
that referenced
this pull request
Oct 30, 2016
* Will Cancel Observer (#293) * [OPR-293]: Refactors Start & Cancellation observers * [OPR-293]: Go back to original group cancellation policy * [OPR-293]: Adds errors to will cancel observer * [OPR-293]: Avoids overriding cancel Instead adds a will cancel observer. * [OPR-293]: Corrects mistake where the queue was not suspended !! * [OPR-293]: Makes cancel a final method This prevents Operation subclasses from overriding cancel. Instead, they should add an observer as appropriate. WillCancelObserver <- block is executed directly before the operation will change its cancellation state. DidCancelObserver <- block is executed directly after the operation did change its cancellation state. Typically, subclasses will want to observe WillCancel to update their own internal state. But consumers will want to observe DidCancel to respond to operations being cancelled. * [OPR-293]: Adds to new operations to property Also makes the queue private. * [OPR-293]: Cancels all operations in the queue. This will ensure that the finishing operation is also cancelled. * [OPR-293]: Adds will/did cancel API * [OPR-293]: Fixes some issues with GroupOperation One of the issues with adding the operations to the queue in the initializer, is that observers will not get notified. So, we have to add the initial operations in `execute`. But, if we append to operations in addOperations, that means, we need to filter out any instances which have already been added. For example, a subclass may well implement execute to first addOperation(myOperation); super.execute() which would cause a crash if we tried adding myOperation twice. * [OPR-293]: Renames will/didFinish This is to be consistent with operationWill/operationDidCancel * Conditions as Operations (#286) * [OPR-278]: Adds protocols for OperationType * [OPR-278]: Creates ConditionOperation With internal types for wrapping OperationCondition, and evaluating groups. * [OPR-278]: Initial work removing ready override. * [OPR-278]: Enables previously failing test * [OPR-278]: Adds missing files to Extension project * [OPR-278]: Enables previously failing test in iOS scheme too * [OPR-278]: Increases the batch size. Also removes the logging. * [OPR-278]: Fixes scheduling of dependencies. * [OPR-278]: Further fixes to dependency scheduling. * [OPR-278]: Removes unnecessary protocols * [OPR-278]: Removes dependency between evaluator and conditons This can introduce a deadlock with mutual exclusivity. * [OPR-278]: Fixes incorrect test with profiler. * [OPR-278]: Enables all tests on OS X * [OPR-278]: Enables all tests on iOS * [OPR-278]: Prevents a retain cycle in ConditionOperation * [OPR-278]: Adds failing test to clarify mutual exclusivity * [OPR-278]: Sets mutual exclusion around operation This was a mistake - it was getting set on the condition. * [OPR-278]: Fixes mutual exclusivity tests * [OPR-278]: Sorts out mutual conditions with dependencies Also, operations which have dependencies, and mutually exclusive conditions which have dependencies. * [OPR-278]: Clean up the code a bit * [OPR-278]: Includes indirect dependencies * [OPR-278]: Starts adding Stress Tests This is a new test bundle which gets tested as part of the OS X test suite. * [OPR-278]: Renames ConditionOperation to Condition It *is* an operation, but I want it to be treated like a Condition with it's own evaluate API * [OPR-278]: Sets up tests * [OPR-278]: Renames to mutuallyExclusive * [OPR-278]: Fixes target reference for Condition.swift * [OPR-278]: Adds ComposedCondition This is useful (and uses automatic result injection) for easily getting the result of a previous condition. * [OPR-278]: Refactors BlockCondition * [OPR-278]: Refactors NegatedCondition * [OPR-278]: Initial work on updating framework conditions - [x] BlockCondition - [x] TrueCondition - [x] FalseCondition - [x] ComposedCondition - [x] SilentCondition - [x] NegatedCondition - [x] MutuallyExclusive - [x] NoFailedDependenciesCondition * [OPR-278]: Corrects a mistake with removeDependencies We we actually just adding?! * [OPR-278]: Mixes the composed direct dependencies * [OPR-278]: Updates UserNotificationCondition to subclass Condition * [OPR-278]: Fixes some tests for iOS * [OPR-278]: Refactors AuthorizedFor * [OPR-278]: Refactors UserConfirmationCondition * [OPR-278]: Refactors ReachabilityCondition * [OPR-278]: Refactors AddressBookCondition * [OPR-278]: Refactors ContactsCondition * [OPR-278]: Refactors RemoteNotificationCondition * [OPR-278]: Adds @available annotation. Still not really sure how to accuractly mark API as deprecated inside a framework. * [OPR-278]: Adds some tests for conditions * [OPR-278]: Refactors condition error type * [OPR-278]: Refactors True False Condition * [OPR-278]: Cleans up Condition tests * [OPR-278]: Fixes tests * Fixes an incorrect Fix-It hint. (#302) Fixes #299. * Fixes notice severity logs (#303) This was done during development and accidentally committed & pushed. Fixes #300 * Fixes bug: CLLocationManager prematurely responds with 'NotDetermined' auth status when asking for permission (#305) * CLLocationAuthorizationStatus bug (#306) * Fixes bug: CLLocationManager prematurely responds with 'NotDetermined' auth status when asking for permission (#305) * [OPR-306]: Adds test coverage for location capability * Improved support for CloudKit Errors (#304) * [OPR-290]: Adds Error associated type on CKOperationType At the moment, this is just fulfilled by NSError, however it will allow us to offer specialized error responses depending on the operation. * [OPR-290]: Updates test cloud kit operation. * [OPR-290]: Adds missing file to Extension project * [OPR-290]: Moves CloudKit sources into a folder * [OPR-290]: Adds errors for Modify Zones & Records * [OPR-290]: Adds custom error types for all CloudKit Operations * [OPR-290]: Fixes error handling Now every CKOperation has it's own bespoke error type. * [OPR-290]: Tidies up AssociatedErrorType * [OPR-290]: Fixes issues with AssociatedErrorType * [OPR-290]: Adds error recovery to BatchedCloudKitOperation * [OPR-290]: Exposes properties on OPRCKOperation These are needed to configure operations inside error handlers. * Removes unnecessary let statement (#310) * Supports entersReaderIfAvailable configuration in WebpageOperation. (#312) It is possible now to show an SFSafariViewController with entersReaderIfAvailable set to false. * Refactors WebpageOperation to subclass ComposedOperation (#315) * Extended WebpageOperation with the ability to configure entersReaderIfAvailable at initialization. It is possible now to show an SFSafariViewController with entersReaderIfAvailable set to false. * Fixed a bug in WebpageOperation that that resulted in a retain cycle. * - Refactored WebpageOperation as ComposedOperation to fix a retain cycle. - Added Documentation. * Fixed some typos in WebpageOperationTests. * Implemented OpenInSafariOperation (#317) * Implemented OpenInSafariOperation * Made the displayControllerFrom non optional. * Refactored OpenInSafariOperation. * Fixes a bug removing dependencies on Condition (#309) The issue is that ComposedCondition must remove the dependency on its composed condition too. * Improves cancellation checks in main() (#319) * [OPR-287]: Invokes observers in main main() is called from start, and we already check that the operation is not cancelled. Therefore the check at the start of main is redundant. However, we don't check after the observers have been executed that the operation is cancelled. * [OPR-287]: SwiftLint fixes. * Exposes LogSeverity enum to Objective-C (#324) * Remove Reachability from CloudKitOperation (#327) * Ignore DS_Store * Rip out reachability from CloudKitOperation * [OPR-327]: Adds trailing closure syntax * [OPR-327]: Adds TimeoutObserver * [OPR-327]: Adds tests for timeout observer * Override NSOperationQueue's mainQueue() (#330) * Override NSOperationQueue's mainQueue() to return the main queue as an OperationQueue * set maxConcurrentOperationCount to 1 * Adds missing functionality of UIAlertController to AlertOperation (#334) * Added missing functionality of UIAlertController to AlertOperation. * Annotated new functionality as public. * Added test cases for new functionality. * Made alert property of AlertOperation private. * SwiftLint corrections. * Added a test for preferredAction and fixed a but related to it. * Made UserIntent enum objc accessbile (#341) * Fixed network observer flickering (#338) Added tests for multiple operations having network observer * Supports error recovery in GroupOperation (#326) * [OPR-326]: Adds Errors subtype in Operation * [OPR-326]: Refactors GroupOperation willFinish API * Revert "[OPR-326]: Adds Errors subtype in Operation" This reverts commit 759f2ef. * [OPR-326]: WIP on group operation errors * [OPR-326]: Fixes issues with retry operation tests This is still not quite right. * [OPR-326]: Allows RetryOperation to fully recover from errors * [OPR-326]: Fixes issue with tests * [OPR-326]: Tweaks ProfilerTest case * [OPR-326]: Refactors ComposedOperation to just subclass GroupOperation * [OPR-326]: Changes behaviour when a group produces an operation * [OPR-326]: Logs when a GroupOperation successfully recovers from errors * [OPR-326]: Logs when the next operation will be added * [OPR-326]: Adds an immediate WaitStrategy * [OPR-326]: Adds the operation to the log when attempting recovery * [OPR-326]: Removes unneeded handling of child errors * [OPR-326]: Allows the WaitStrategy to be defined at init * [OPR-326]: Changes to support ComposedOperation * [OPR-326]: Speeds up CloudKit tests with .Immediate wait strategy * [OPR-326]: WIP on GroupOperation errors * [OPR-326]: Fixes a bug where operation would not retry In the case where there is a default handler, but no custom one set for the same error. * [OPR-326]: Renames internal methods to be more Swifty * [OPR-326]: Fixes errors - whoops. * Always create CLLocationManager on the main queue (#321) * [OPR-321]: Creates CLLocationManager on the main thread Also makes it thread safe. * [OPR-321]: Refactors capability to use guard & early exit. * [OPR-321]: Creates CLLocationManager lazily on the main thread Refactors UserLocationOperation to not use generic at the same time * [OPR-321]: Fixes deadlock in creating CLLocationManager * [OPR-321]: Refactors location operations for early exit * [OPR-321]: Removes use of NSThread to check for main queue * [OPR-321]: Fixes a mistake with the merge * RepeatedOperation allows for configuration block to be reset by the payload (#348) * [OPR-332]: Adds support for RetryOperation to provide a configuration block * [OPR-332]: Removes commented out code * [OPR-332]: Adds test to check that configure block is replaced * Turns on Whole Module Optimization (#350) Fixes #349 * Exposes the UIAlert for customization. (#351) This also fixes a bug where it wasn't possible to set a barButtonItem on an ActionSheet while presenting as a popover. * Fixes OperationQueue.delegate crash (SR-192) (#353) * Add failing test test__SR_192_OperationQueue_delegate_weak_var_thread_safety: Tests race condition (and crash) involving OperationQueue’s weak delegate var. * Fix for OperationQueue.delegate crash (SR-192) The underlying error is in Swift < 3.0, with concurrent reads of weak properties. See: https://bugs.swift.org/browse/SR-192 This change wraps the public delegate property with an NSLock. It also sets it to nil first-thing in deinit to safely get rid of it. * Simplistic support for CKLimitExceeded error handling (#294) * [OPR-294]: Initial work adding built in support for CKLimitExceeded * [OPR-294]: Rewrite with support for nil response * [OPR-294]: Adds support for adding error handlers in bulk * [OPR-294]: Fixes some comments * [OPR-294]: Moves error handling to CloudKitError * [OPR-294]: Adds BatchProcessErrorType This is only needed for CKMarkNotificationsOperation * [OPR-294]: Renames error protocols * [OPR-294]: Adds support for batch processing * [OPR-294]: Adds & Refactors for tests * [OPR-294]: Minor tweaks * [OPR-294]: Further tweaks * [OPR-294]: Fixes error in bisect * [OPR-294]: Adds API to replace the configure block outright * [OPR-294]: Fixes failing tests * [OPR-294]: Refactors stress tests condition * Adds TaskOperation (#355) * [OPR-313]: Adds TaskOperation * [OPR-313]: Adds more test coverage * [OPR-313]: Adds header documentation * Vastly improves thread safety in Operations (#358) * FIX: GroupOperation.operations contains the initial operations twice after beginning to execute. Cause: `GroupOperation.execute()` calls `GroupOperation.addOperations(operations)`, which then re-adds the operations back to the operations array. Solution: Added a private **`_addOperations()`** method to `GroupOperation` with an additional flag to override this behavior - used in `GroupOperation.execute()`. `addOperations()` now calls this private implementation method. * Operation.cancel(), Operation.finish() thread-safety - `Operation.cancel()` now acquires the stateLock. - `Operation.finish()` now acquires the stateLock. - `stateLock` is now NSRecursiveLock(). - var `Operation.cancelled` is thread-safe. - var `Operation.errors` is thread-safe. - Explicitly send KVO notifications on NSOperation keyPaths at the right times, avoiding lots of unnecessary notifications. - Removed “State” KVO notifications. (Previously used to trigger NSOperation isExecuting/isFinished notifications, which are now triggered explicitly.) - Added missing operationWillFinish() call to finish(). - operationDidFinish() now happens after the state has been set to .Finished. - `Operation.cancelWithError(errors)` now asserts if it’s called while the Operation is finishing or finished. * Operation.main() thread-safety, Operation.disableAutomaticFinishing - `Operation.main()` acquires the stateLock when appropriate. - `Operation.main()` manually sends the isExecuting NSOperation KVO notifications when setting executing state. - Added ability to disable Operation’s automatic calling of finish(), with `init(disableAutomaticFinishing: Bool)`. (Defaults to existing behavior - i.e. false.) * GroupOperation improvements (finish and thread-safety) - GroupOperation should only finish() after its children have finished. - `GroupOperation._addOperations()` acquires the stateLock. - `GroupOperation._addOperations()` cancels new child operations if the GroupOperation is cancelled. * RepeatedOperation.addNextOperation() must check cancelled - RepeatedOperation.addNextOperation() now checks cancelled status. * Added new cancellation-related tests * Added new GroupOperation tests * Added Operation KVO notification tests (for NSOperation keyPaths) * Fixed spurious commit * Handle more possible cases in Operation.main() - Check that the Operation is not already executing. - Check that the Operation has not been finished by a WillExecute observer (either directly or as a side-effect of something else). Added a test case that demonstrates this possibility. * Add missing super.init() calls * More GroupOperation cancelling fixes - Changed the internal WillCancelObserver to a DidCancelObserver to ensure that the cancelled state has been set prior to cancelling child operations. (This ensures that side-effects of propagating cancellation to child operations - like RepeatedOperation attempting to add the next operation - can safely check the cancelled status.) * GroupOperation should not call queue.cancelAllOperations() Calling queue.cancelAllOperations() also cancels the finishingOperation, which skips properly waiting until all other child operations are finished. Fixed test. * Added willProduceOperation method to OperationQueueDelegate, fix GroupOperation handling of child-produced operations Informational method only. This enables GroupOperation to add child-produced operations to its internal operations array, and thus cancel them when the GroupOperation is cancelled. Added tests. * GroupOperation should ignore queue delegate calls from other queues Added missing guard at the top of the queue delegate methods in GroupOperation. Added test to illustrate simple failure case this change covers. * Refactor lock usage in Operation.finish() and .cancel() - Refactor lock usage to hold the stateLock only when necessary or manipulating internal state, and *not* when sending KVO notifications or notifying observers. - Improvements and fixes to KVO Notification Tests. * Further refactor lock usage in Operation (.execute()) - Refactor lock usage in `Operation.execute()` to hold the stateLock only when necessary or manipulating internal state, and *not* when sending KVO notifications or notifying observers. * Add a number of new StressTests that previously failed/crashed New tests have support for a `batches` parameter. * Initial fix for Logging-related crashes (thread-safety issues) - `Operation._log` must not be a lazy var. From the Swift book: > If a property marked with the lazy modifier is accessed by multiple threads simultaneously and the property has not yet been initialized, there is no guarantee that the property will be initialized only once. For more: https://bugs.swift.org/browse/SR-1042 - `Operation.log` must be thread-safe. Initial fix involves capturing a copy of the logging context (settings + operationName) at the time of access of `Operation.log`, returning that captured context as a LoggerType, and surrounding access of .log with a Read/Write lock. - LogManager properties must be thread-safe. * Refactor lock usage in GroupOperation - var `GroupOperation.operations` is now thread-safe. - GroupOperation now utilizes a private CanFinishOperation to safely transition to executing the finishingOperation. (See code & comments.) - GroupOperation now has its own lock that is used sparingly to protect finishing state. - `GroupOperation._addOperation()` now utilizes the groupFinishLock. * Minor tweaks - `Operation.stateLock` should remain private. * SwiftLint clean-up * Refactor lock usage in GroupOperation - Refactor lock usage to hold the groupFinishLock only when necessary or manipulating internal state, and *not* when sending KVO notifications, notifying observers, or changing additionalOperations state (which might send KVO notifications or notify observers). * Clean-up - Remove asserts from `Operation.cancelWithErrors()`. Operation cancellation methods should be safe to call at any time without asserting. - Other minor tweaks. * Clean-up - Moved NSOperationKeyPaths to extension NSOperation.KeyPath enum. * Clean-up * Clean-up - Remove unneeded `self.` * Clean-up * Clarify docs & re-formatting * Add new inits to Queue (NSQualityOfService and qos_class_t) Per code review. * Clean-up of GroupOperation * Make Operation.cancel() final (#359) Per discussion in: #293 #358 (comment) * Supports composing simple types for Result injection (#362) * [OPR-362]: Linting whitespace changes * [OPR-362]: Adds support for composing “executors” inside a final Operation type This is a convenience class to aid adoption of _Operations_ without requiring types to subclass Operation. Instead, classes only need to conform to Executor, and then can use the Execute class, which support cancellation, and result injection. * Supports async executors (#363) * Fixes a finished log message (#365) The "Operation Did finish" log was using the opposite logic for error logging * Group's internal queue is non-public; exposes appropriate properties (#361) * Make GroupOperation's internal queue non-public, and expose appropriate properties on GroupOperation - Make GroupOperation.queue ~private~internal. (So it can be tested.) - Expose appropriate run-time editable properties of the GroupOperation’s queue as properties on GroupOperation. Specifically: - public var maxConcurrentOperationCount: Int - public var suspended: Bool - public var qualityOfService: NSQualityOfService - Add tests. * [OPR-361]: Support underlying queue in Group * GatedOperation cancels composed operation when gate is closed (#377) * [OPR-377]: Adds early exit with guard * [OPR-377]: Refactors GatedOperation execute * [OPR-377]: Fixes typo * Result Injection protocol improvements (#378) * [OPR-378]: Updates result injection APIs * [OPR-378]: Adds unit tests * [OPR-378]: Removes unnecessary weak self capture * Fixes dependency gets added twice if it's direct & indirect (#379) * [OPR-379]: Adds a failing unit test * [OPR-379]: Makes indirect dependencies unique set * Removes TaskOperation from non-macOS platforms (#382) * Removes AlertPresentation mutual exclusion (#383) * Adds IgnoredCondition (#385) * Filters out indirect dependencies which have already been added (#386) * Fixes issues with ignored condition (#390) This means that conditions which are ignored mean that the attached operation does not execute, but also does not finish with an error. It’s a nicer use case than GatedOperation. This works by checking the OperationResult for .Ignored and then only cancel() instead of cancelWithError(). Note that if the operation also has .Failed(errors) condition result, in addition to .Ignored then the operation will still not run but this time with errors (as expected). Note that if the operation also has .Satisfied condition result, in addition to .Ignored then the operation will not run, but without errors. * NoFailedDependenciesCondition supports ignoring cancelled operations (#397) Fixes #396. * [OPR-396]: NoFailedDependenciesCondition support ignoring cancels * [OPR-396]: Refactors initializer * [OPR-396]: Renames the condition * Ability to add configuration to the next (retried) CloudKitOperation (#395) * Adds CloudKitOperation.setPrepareForRetryHandler() * Adds BatchedCloudKitOperation.setPrepareForNextOperationHandler() * Clean-up * Updated new APIs, added documentation -Simpler, cleaner, better APIs. -Added documentation and examples for the new APIs. * Add documentation for BatchedCloudKitOperation. * Updates project header (#399) * [OPR-399]: Updates the header * [OPR-399]: Updates the README to point to the new URL for header * Updates guidelines (#400) * [OPR-400]: Updates copyright holders to “ProcedureKit” * [OPR-400]: Adds a code of conduct * [OPR-400]: Fixes a markdown formatting issue * [OPR-400]: Adds CONTRIBUTING guidelines * [OPR-400]: Moves CONTRIBUTING to .github directory * [OPR-400]: Removes an empty section * [OPR-400]: Adds instruction on adding verbose logs. * [OPR-400]: Updates CONTRIBUTING guideline * [OPR-400]: Updates README too * [OPR-400]: Fixes some typos * Creates ProcedureKit project (#401) * [OPR-401]: Sets up ProcedureKit project * [OPR-401]: Adds ProcedureKitMobile This will cover iOS & watchOS * [OPR-401]: Adds ProcedureKitTV * [OPR-401]: Fixes Runtime Search Paths * [OPR-401]: Adds StressTests * [OPR-401]: Adds ProcedureKitMac * [OPR-401]: Enables code coverage on all testable schemes * [OPR-401]: Adds ProcedureKitCloud * [OPR-401]: Changes to module imports * [OPR-401]: Changes Cloud to latest deployment versions * ProcedureKit CI - Stage 1 (#403) * [OPR-403]: Changes Stress Tests to only run as part of the ProcedureKitMac scheme * [OPR-403]: Changes Cloud minimum target versions * [OPR-403]: Adds tests to CI - ProcedureKit macOS * [OPR-403]: Fixes Operations mac tests * [OPR-403]: Fixes Operations tests 2 * [OPR-403]: Fixes Swift version to 2.2 * [OPR-403]: Moves common scripts around * [OPR-403]: Updates scripts * [OPR-403]: Changes to the Fastlane name for mac * [OPR-403]: Updates build dependencies * [OPR-403]: Sets the correct destination platform * [OPR-403]: Updates scan invocation * [OPR-403]: Updates Fastfile * [OPR-403]: Trying to use which to find bundle * [OPR-403]: Using quotes * [OPR-403]: Adds setup first * [OPR-403]: Putting the whole setup into quotes * [OPR-403]: Attempting to add multiple lines to the command * [OPR-403]: Puts it all on one line * [OPR-403]: Adds more ProcedureKit steps * [OPR-403]: Fixes error in Stress Tests build settings * [OPR-403]: Pipline Uploads * [OPR-403]: Fixes pipelines * [OPR-403]: Uses pipeline upload correctly * [OPR-403]: Fixes error in mobile tests * [OPR-403]: Adds watchOS * [OPR-403]: Removes automatic code signing * [OPR-403]: Comments out watchOS builds * [OPR-403]: Adds TV * [OPR-403]: Removes ad-hoc code signing * [OPR-403]: Fixes Operations iOS * [OPR-403]: Sets iPhone Developer automatic code signing * [OPR-403]: Updates buildkite agent tags for iOS Simulator * [OPR-403]: Sets the development team in xcargs * [OPR-403]: Enables automatic code signing without a team set * [OPR-403]: Fixes issues with code signing settings for TV * [OPR-403]: Removes the development team * [OPR-403]: Puts everything into a single pipeline * [OPR-403]: Cleans up the pipeline * [OPR-403]: Sets personal team for mobile unit tests * [OPR-403]: Updates the Fastlane lane names * [OPR-403]: Adds a copy frameworks build phase * [OPR-403]: Removes copy files phase * [OPR-403]: Comments out problematic build jobs * [OPR-403]: Removes Operations CI jobs * ProcedureKit CI - Stage 2 (#404) * Update CI dependencies (#409) * [OPR-409]: Updates dependencies and enables pipeline * [OPR-409]: Fixes YML * [OPR-409]: Fully specifies the destination Starting to really not like Fastlane * [OPR-409]: Switches to iOS 10 simulators. * [OR-409]: Sets the developer directory * [OPR-409]: Removes tvOS for Mobile framework * [OPR-409]: Reorders the jobs * Add base types to ProcedureKit (#405) * [OPR-405]: Creates Procedure * [OPR-405]: Sets the Swift version * [OPR-405]: Cleans project * [OPR-405]: Changes to destination * [OPR-405]: Stops using Fastlane for testing macOS * [OPR-405]: Adds initial files for ProcedureQueue * [OPR-405]: Defines ProcedureObserver * [OPR-405]: Adds the default implementation of ProcedureObserver * [OPR-405]: Adds the rest of the observer protocols * [OPR-405]: Adds @available annotations * [OPR-405]: Adds block based observers * [OPR-405]: Adds Protector / DispatchQueue extension * [OPR-405]: Further updates to observers API * [OPR-405]: Adds extension to Operation This is for addCompletionBlock - but will be used for more stuff when we get into dependencies * [OPR-405]: Fixes lint issues * [OPR-405]: Adds Procedure protocol with AbstractProcedure * [OPR-405]: Starts interfaces in AbstractProcedure for execute & finish * [OPR-405]: Adds state transition * [OPR-405]: Refactors Procedure to be protocol based. * [OPR-405]: Adds most of the cancellaton functionality * [OPR-405]: Adds main implementation With a few TODOs * [OPR-405]: Fixes available renames * [OPR-405]: Changes AbstractProcedure back to Procedure * [OPR-405]: Adds Testing framework With TestProcedure class * [OPR-405]: Adds basic API to ProcedureTestCase * [OPR-405]: Updates dependencies * [OPR-405]: Commenting out non mac unit tests Run CI on iOS Simulators is basically impossible on beta version of Xcode. * [OPR-405]: Adds finishing and cancellation tests * [OPR-405]: Adds some finishing tests * Adds Logging (#428) * [OPR-428]: Adds LogSeverity * [OPR-428]: Adds logger * [OPR-428]: Updates logging stuff * [OPR-428]: Adds logging tests * Group (#430) * [OPR-430]: Adds Group * [OPR-430]: Adds initializers to Group * [OPR-430]: Adds add child API to Group * [OPR-430]: Corrects spelling * [OPR-430]: Adds finishing APIs to Group * [OPR-430]: Adds extension of unavailable APIs * [OPR-430]: Adds GroupObserverProtocol * [OPR-430]: Adds error handling and recovery to Group * [OPR-430]: Improves group observers API * [OPR-430]: Adds first group test * [OPR-430]: Adds some basic tests for Group * [OPR-430]: Adds more unit test for Group * [OPR-430]: More tests for group * Adds User Intent (#439) * [OPR-439]: Adds UserIntent to Procedure * [OPR-439]: Adds userIntent to Group * Stress Tests Phase 1 (#442) * [OPR-442]: Adds StressTestCase and completion block stress tests * [OPR-442]: Uses StressLevel directly. * [OPR-442]: Refactors the test case names * [OPR-442]: Refactors to remove StressTestCase Instead the stress function can be added to the base ProcedureKitTestCase * [OPR-442]: Adds group cancel stress test * [OPR-422]: Refactors group stress tests These are currently failing * [OPR-422]: Refactors schemes, as stress tests are run as part of Mac tests * [OPR-442]: Updates Stress Tests batches Uses intermediate BatchProtocol, and exposes a measure API. * [OPR-422]: Changes the active developer directory * [OPR-422]: Adds group child finishing order stress test * [OPR-422]: Fixes incorrect pipeline step * [OPR-422]: Adds more stress tests for Procedure * [OPR-422]: Fixes TestError mistake * [OPR-422]: Changes to use didCancelBlockObserver Instead of didFinishBlockObserver - there might be a subtle bug here. * [OPR-422]: Disables some checks - have identified that there is definitely an error in finishing logic * [OPR-422]: Moves stress tests to their own scheme * [OPR-422]: Adds stress fastlane * [OPR-422]: Trying to see how to trigger stress tests * [OPR-422]: Removing - * [OPR-422]: Changes the trigger to ProcedureKit * [OPR-422]: Add the pipeline update step back * [OPR-422]: Fixes yml * [OPR-422]: More changes to pipeline template * [OPR-422]: Fixes the slug This is case sensitive! * [OPR-422]: Triggers a different pipeline stress tests * [OPR-422]: Adds commit message to stress test build * [OPR-422]: Modifies measure to be a little quicker * [OPR-422]: Updates baselines with Mac Pro * [OPR-422]: Fixes mistake with finishing from cancel * Fix issue with newlines in pipeline upload (#445) * [OPR-445]: Removes message from upload script * [OPR-422]: Puts the commit back * Initial work on Result Injection (#446) * Adds Dependencies & Conditions (#429) * [OPR-429]: Adds Condition protocol and class * [OPR-429]: Adds conditions to procedure and queue * [OPR-429]: Adds tests for Conditions Also adds XCTAssertProcedure functions to make verifying Procedure behaviour more consistent. * [OPR-429]: Adds remaining unit tests for conditions Still got Ignored Condition to add * [OPR-429]: Fixes some documentation * [OPR-429]: Performs the stress tests in the same build * [OPR-422]: Adds stress tests for conditions * [OPR-429]: Adds IgnoredCondition * ProcedureKitError (#437) * [OPR-437]: Regorganized the Core group * [OPR-437]: Refactors Errors into ProcedureKitError * Completes Result Injection API test coverage (#447) * [OPR-447]: Sorts out ResultInjection * [OPR-447]: Completes result injection tests * Fixes Xcode 8 GM issues (#463) * BlockProcedure (#450) * [OPR-450]: Adds BlockProcedure * [OPR-450]: Adds unit tests for map and block procedures * [OPR-450]: Adds some stress tests for block procedure * [OPR-450]: Updates stress tests * [OPR-450]: Fixes Xcode 8 GM escaping issue * [OPR-450]: Papers over some possible issues with finishing. In many cases the `should finish after cancelling` logic is returning false. * [OPR-450]: Removes some excessive logging * [OPR-450]: Adjusts variation to 15% * Mutual exclusive conditions (#448) * [OPR-448]: Adds MutualExclusion * [OPR-448]: Adds support for adding dependencies for mutual exclusion * [OPR-448]: WIP on mutual exclusivity * [OPR-448]: Finishes off test cases for mutual exclusivity * [OPR-448]: Refactors add condition API to attach condition I want to make the API consistent - but not choose consistency over intent. So, `add(dependency: myDependency)` makes sense - as it signals that the dependency is already managed by some other queue/system. Where as for a Condition, we specifically _attach_ it to Procedure instance, and it does not (ideally should not) be managed outside the Procedure. So, I want the concept of “attaching conditions to procedures” to be the language which is used to describe the behaviour. * DelayProcedure (#449) * [OPR-449]: Adds delay procedure * [OPR-449]: Adds DelayProcedure tests * Renames Group to GroupProcedure (#468) * Adds ProcedureKit.podspec (#467) * Adds NegatedCondition (#471) * Adds SilentCondition (#472) * Procedure finishing fixes (#474) * Resolve finishing issues related to FinishingFrom. * Add StressTest that covers concurrent calls to finish() * Revert ProcedureKitTestCase expectation fulfillment back to the main queue. * Adds BlockCondition (#473) * Adds NoFailedDependenciesCondition (#470) * Adds TimeoutObserver (#475) * [OPR-475]: Adds TimeoutObserver * [OPR-475]: Fixes issues with TestProcedure It was not correctly delaying. * Procedure name and identity (#478) * [OPR-478]: Adds name and Identity * [OPR-478]: Fixes some failing tests * [OPR-478]: Fixes another failing name test * Adds BlockObserver (#480) * [OPR-480]: Adds BlockObserver * [OPR-480]: Tweaks to stress tests * Adds ComposedProcedure & GatedProcedure (#487) * RepeatProcedure (#488) * [OPR-488]: Initial work on RepeatProcedure * [OPR-488]: Adds remaining test coverage * RetryProcedure (#491) * [OPR-491]: Adds RetryProcedure * [OPR-491]: Unifies the generic init pattern for repeat and retry procedures * Adds support for Capabilities (#492) * [OPR-492]: Fixes incorrectly spelt protocol * [OPR-492]: Adds Capability Including CapabilityProtocol, GetAuthorizationStatus, Authorize, AuthorizedFor * Adds BackgroundObserver (#476) * [OPR-476]: Fixes stress tests * [OPR-476]: Adds BackgroundObserver * [OPR-476]: Gets the Mobile test suite working * [OPR-476]: Switches code coverage on * [OPR-476]: Adds missing callback This was causing a failing unit test * [OPR-476]: Removes unnecessary build phase * [OPR-476]: Finishes BackgroundObserver tests * [OPR-476]: Removes verbose logging in test case * Adds FilterProcedure (#496) * [OPR-496]: Adds FilterProcedure * [OPR-496]: Adds filter method for when Result is a sequence * Adds ReduceProcedure (#497) * [OPR-497]: Adds ReduceProcedure * [OPR-497]: Refactors Map, Filter adds FlatMap MapProcedure is really a TransformProcedure. MapProcedure and FilterProcedure are now simple subclasses of ReduceProcedure, along with FlatMapProcedure. * Adds NetworkObserver (#498) * [OPR-498]: Adds NetworkObserver Additionally, this updated ProcedureKitTestCase to automatically add async expectation fulfills around operations which might be produced by a procedure. * [OPR-498]: Refactors ProcedureKitTestCase slightly for Swift 3 conventions. * Adds Location.Capability (#499) * [OPR-499]: Adds ProcedureKitLocation framework * [OPR-499]: Supports sychronous dispatch onto the main queue This is safe to call if already on the main queue. * [OPR-499]: Adds Capability.Location * Adds UserLocationProcedure (#500) * [OPR-500]: Adds UserLocationProcedure * [OPR-500]: Removes unneeded error struct * [OPR-500]: Fixes issue with tvOS * Corrects minimum deployment targets (#503) Fixes #501 * [OPR-501]: Fixes issues with deployment versions * [OPR-501]: Setting tvOS to 9.2 * Adds ReverseGeocodeProcedure (#502) * [OPR-502]: Adds ReverseGeocodeProcedure * [OPR-502]: Adds ProcedureKitMobile as a build dependency * [OPR-502]: Fixes a mistake where macOS location tests were requiring iOS simulator * [OPR-502]: Uses gym to ensure iOS builds ProcedureKitMobile before testing Location * [OPR-502]: Use scan instead of gym This is a hack. I want to make sure that when we test ProcedureKitLocation on iOS we have build ProcedureKitMobile. * Adds ReverseGeocodeUserLocationProcedure (#504) * [OPR-504]: Adds/renames files * [OPR-504]: Adds ReverseGeocodeUserLocationProcedure * [OPR-504]: Rounds out the unit tests on ReverseGeocodeUserLocationProcedure * Makes procedures open where appropriate (#510) * Refactors BlockProcedure (#511) * Adds AnyProcedure (#516) * [OPR-516]: Removes import foundation This is done by the prefix header * [OPR-516]: Adds AnyProcedure * [OPR-516]: Uses the correct underlying queue throughout AnyProcedure * Fixes regression of failing release build (#518) * Renames AuthorizationStatusProtocol to AuthorizationStatus (#519) * Renames capability reated procedures (#520) * Renames attach(condition: Condition) to add (#521) * Adds Capability.CloudKit (#523) * [OPR-523]: Adds Capability.CloudKit * [OPR-523]: Enables CI builds for CloudKit stuff on iOS and tvOS * Adds ProcedureKitNetwork framework (#524) * [OPR-524]: Adds ProcedureKitNetwork framework * [OPR-524]: Adds Network to CI jobs * [OPR-524]: Renames Stress Tests job * [OPR-524]: Shares the network scheme * [OPR-524]: Imports Foundation instead of Cocoa * [OPR-524]: Forces Stress Tests onto a non-simulator agent * Adds NetworkDataProcedure (#525) * [OPR-525]: Adds NetworkDataProcedure * [OPR-525]: Fixes up some unit tests * [OPR-525]: Adds missing test coverage * Moves TestableNetwork into TestingProcedureKit framework (#526) * Refactors injectDependency API to be an extension on ProcedureProtocol instead. (#527) * Adds transform block result injection API (#528) * [OPR-528]: Refactors result injection Uses an intermediatory injectResult(from: via:) API, which allows the caller to provide a throwing block to transform the result into the requirement. * [OPR-528]: Removes unneeded return * [OPR-528]: Fixes error in ProcedureKitLocation * Adds default empty implementations some queue delegate methods (#531) Only added the will-do-something ones. Fixes #530 * Adds space in the repo for presentations (#533) * [OPR-533]: Adds CocoaHeads Stockholm talk Contact @danthorpe if you want the original Keynote file. * [OPR-533]: Adds Sky-UK iOS Community Talk * [OPR-533]: Adds a presentations README * Disables the log for AnyProcedure (#534) * Fixes bug where GroupProcedure collects errors from children after its been cancelled (#532) * [OPR-532]: Adds failing test * [OPR-532]: Checks cancelled state of the group We can exit this delegate callback early if the group has already been cancelled. * [OPR-532]: Removes default implementation of willFinish It seems that adding default implementations here causes some odd behaviour / intermittent crash where this is overwritten in the QueueDelegate. * [OPR-532]: Fixes a unit test which is now mis-counting errors. * Adds .then { } API (#536) * [OPR-176]: Adds then extension on Operation * [OPR-176]: Implements .then { } API * [OPR-176]: Adds enqueue method to a collection of Operations * [OPR-176]: Fixes header docs * Removes default argument for session in NetworkDataProcedure (#538) * Tweaks the cancel block procedure stress tests (#539) There might be an underlying issue. As normally a batch of 10_000 finishing in ~ 5 seconds. But sometimes fails because it times out, meaning that an expectation is not getting fulfilled. * Moves ProcedureKit imports to umbrella headers (#540) * [OPR-540]: Putting the appropriate imports into umbrella headers * [OPR-540]: Fixing issues with importing ProcedureKit into TestingProcedureKit * Updates ProcedureKit podspec with subspecs (#508) * [OPR-508]: Lints podspec without an warnings or errors. * [OPR-508]: Fixes errors running tests * Adds ResilientNetworkProcedure (#537) * [OPR-537] Adds ResilientNetworkProcedure * [OPR-537]: Updates retry request with error code * [OPR-537]: Adds edge case for ResilientNetworkProcedure In some situations, the HTTP status code might well require (depending on the behaviour) a retry. * [OPR-537]: Fixes simple unit tests * Refactor ResultInjection to use PendingValue enum (#541) * [OPR-541]: Refactors ResultInjectionProtocol to use PendingValue enum * [OPR-541]: Renames ResultInjectionProtocol to ResultInjection * Fixes BlockProcedure stress tests (#544) * [OPR-544]: Fix test__cancel_block_procedure() failures It was possible for the testing BlockProcedure to finish prior to the `block.cancel()` call, which would result in some of the BlockProcedures never cancelling (as they had finished first), and a failing test. Fixed by using a semaphore inside the BlockProcedure’s block. Additionally, the test now waits for all BlockProcedures to cancel *and* finish. * [OPR-544]: Added a new stress test for BlockProcedure cancelling & finishing behavior (allowing for possible races between cancelling and finishing) * Fixes ExclusivityManager synchronization bug (#545) Fixes #543 The ExclusivityManager was using `DispatchQueue.initiated`, which returns a global **concurrent** queue, however its internals are dependent upon **serial** execution of add/remove. Modified to use a serial queue. * Adds ResultProcedure and overloads injectResult(from:) (#546) * Adds HTTPResult<Payload> (#547) * Fix test crashes caused by QueueTestDelegate (#549) QueueTestDelegate was not thread-safe. This could result in crashes running random tests. Fixed by making QueueTestDelegate’s methods thread-safe. * Adds ProcedureKitTestCase wait function that takes an array (#552) * Adds TestingProcedureKit podspec (#553) * Adds Mutual Exclusivity concurrency testing (#550) * Add ConcurrencyTestCase Exposes functionality to test operation concurrency. * Add Mutual Exclusivity concurrency tests * Refactored ConcurrencyTestCase * Refactored ConcurrencyTestCase * Adds didExecuteObserver (#554) * [OPR-554]: Adds code with failing test * [OPR-554]: Calls didExecuteObservers * [OPR-554]: Fixes a typo * [OPR-554]: Adds some documentation to the DidExecuteObserver * Fixes mistake in Fastfile (#557) * [OPR-557]: Fixes error in Fastfile * [OPR-557]: Removes duplicate scan I remember now, as part of location, we used to build Mobile too - because there was a dependency on iOS. But this has since been removed. * Fixes release configuration issues with Xcode 8.1 (#559) Fixes #548 * [OPR-548]: Fixes issue with Xcode 8.1 release configuration * [OPR-548]: Fixes some SwiftLint warnings. * [OPR-548]: Fixes Xcode project warnings in Xcode 8.1 * Adds GroupProcedure concurrency tests (#556) * Add GroupConcurrencyTestCase * Add GroupProcedure.maxConcurrentOperationCount tests * [4.0.0.beta.4]: Sets the version to 4.0.0.beta.4 * [4.0.0.beta.4]: Updates CHANGELOG * [4.0.0.beta.4]: Fixes formatting of CHANGELOG
danthorpe
added a commit
that referenced
this pull request
Nov 28, 2016
* Will Cancel Observer (#293) * [OPR-293]: Refactors Start & Cancellation observers * [OPR-293]: Go back to original group cancellation policy * [OPR-293]: Adds errors to will cancel observer * [OPR-293]: Avoids overriding cancel Instead adds a will cancel observer. * [OPR-293]: Corrects mistake where the queue was not suspended !! * [OPR-293]: Makes cancel a final method This prevents Operation subclasses from overriding cancel. Instead, they should add an observer as appropriate. WillCancelObserver <- block is executed directly before the operation will change its cancellation state. DidCancelObserver <- block is executed directly after the operation did change its cancellation state. Typically, subclasses will want to observe WillCancel to update their own internal state. But consumers will want to observe DidCancel to respond to operations being cancelled. * [OPR-293]: Adds to new operations to property Also makes the queue private. * [OPR-293]: Cancels all operations in the queue. This will ensure that the finishing operation is also cancelled. * [OPR-293]: Adds will/did cancel API * [OPR-293]: Fixes some issues with GroupOperation One of the issues with adding the operations to the queue in the initializer, is that observers will not get notified. So, we have to add the initial operations in `execute`. But, if we append to operations in addOperations, that means, we need to filter out any instances which have already been added. For example, a subclass may well implement execute to first addOperation(myOperation); super.execute() which would cause a crash if we tried adding myOperation twice. * [OPR-293]: Renames will/didFinish This is to be consistent with operationWill/operationDidCancel * Conditions as Operations (#286) * [OPR-278]: Adds protocols for OperationType * [OPR-278]: Creates ConditionOperation With internal types for wrapping OperationCondition, and evaluating groups. * [OPR-278]: Initial work removing ready override. * [OPR-278]: Enables previously failing test * [OPR-278]: Adds missing files to Extension project * [OPR-278]: Enables previously failing test in iOS scheme too * [OPR-278]: Increases the batch size. Also removes the logging. * [OPR-278]: Fixes scheduling of dependencies. * [OPR-278]: Further fixes to dependency scheduling. * [OPR-278]: Removes unnecessary protocols * [OPR-278]: Removes dependency between evaluator and conditons This can introduce a deadlock with mutual exclusivity. * [OPR-278]: Fixes incorrect test with profiler. * [OPR-278]: Enables all tests on OS X * [OPR-278]: Enables all tests on iOS * [OPR-278]: Prevents a retain cycle in ConditionOperation * [OPR-278]: Adds failing test to clarify mutual exclusivity * [OPR-278]: Sets mutual exclusion around operation This was a mistake - it was getting set on the condition. * [OPR-278]: Fixes mutual exclusivity tests * [OPR-278]: Sorts out mutual conditions with dependencies Also, operations which have dependencies, and mutually exclusive conditions which have dependencies. * [OPR-278]: Clean up the code a bit * [OPR-278]: Includes indirect dependencies * [OPR-278]: Starts adding Stress Tests This is a new test bundle which gets tested as part of the OS X test suite. * [OPR-278]: Renames ConditionOperation to Condition It *is* an operation, but I want it to be treated like a Condition with it's own evaluate API * [OPR-278]: Sets up tests * [OPR-278]: Renames to mutuallyExclusive * [OPR-278]: Fixes target reference for Condition.swift * [OPR-278]: Adds ComposedCondition This is useful (and uses automatic result injection) for easily getting the result of a previous condition. * [OPR-278]: Refactors BlockCondition * [OPR-278]: Refactors NegatedCondition * [OPR-278]: Initial work on updating framework conditions - [x] BlockCondition - [x] TrueCondition - [x] FalseCondition - [x] ComposedCondition - [x] SilentCondition - [x] NegatedCondition - [x] MutuallyExclusive - [x] NoFailedDependenciesCondition * [OPR-278]: Corrects a mistake with removeDependencies We we actually just adding?! * [OPR-278]: Mixes the composed direct dependencies * [OPR-278]: Updates UserNotificationCondition to subclass Condition * [OPR-278]: Fixes some tests for iOS * [OPR-278]: Refactors AuthorizedFor * [OPR-278]: Refactors UserConfirmationCondition * [OPR-278]: Refactors ReachabilityCondition * [OPR-278]: Refactors AddressBookCondition * [OPR-278]: Refactors ContactsCondition * [OPR-278]: Refactors RemoteNotificationCondition * [OPR-278]: Adds @available annotation. Still not really sure how to accuractly mark API as deprecated inside a framework. * [OPR-278]: Adds some tests for conditions * [OPR-278]: Refactors condition error type * [OPR-278]: Refactors True False Condition * [OPR-278]: Cleans up Condition tests * [OPR-278]: Fixes tests * Fixes an incorrect Fix-It hint. (#302) Fixes #299. * Fixes notice severity logs (#303) This was done during development and accidentally committed & pushed. Fixes #300 * Fixes bug: CLLocationManager prematurely responds with 'NotDetermined' auth status when asking for permission (#305) * CLLocationAuthorizationStatus bug (#306) * Fixes bug: CLLocationManager prematurely responds with 'NotDetermined' auth status when asking for permission (#305) * [OPR-306]: Adds test coverage for location capability * Improved support for CloudKit Errors (#304) * [OPR-290]: Adds Error associated type on CKOperationType At the moment, this is just fulfilled by NSError, however it will allow us to offer specialized error responses depending on the operation. * [OPR-290]: Updates test cloud kit operation. * [OPR-290]: Adds missing file to Extension project * [OPR-290]: Moves CloudKit sources into a folder * [OPR-290]: Adds errors for Modify Zones & Records * [OPR-290]: Adds custom error types for all CloudKit Operations * [OPR-290]: Fixes error handling Now every CKOperation has it's own bespoke error type. * [OPR-290]: Tidies up AssociatedErrorType * [OPR-290]: Fixes issues with AssociatedErrorType * [OPR-290]: Adds error recovery to BatchedCloudKitOperation * [OPR-290]: Exposes properties on OPRCKOperation These are needed to configure operations inside error handlers. * Removes unnecessary let statement (#310) * Supports entersReaderIfAvailable configuration in WebpageOperation. (#312) It is possible now to show an SFSafariViewController with entersReaderIfAvailable set to false. * Refactors WebpageOperation to subclass ComposedOperation (#315) * Extended WebpageOperation with the ability to configure entersReaderIfAvailable at initialization. It is possible now to show an SFSafariViewController with entersReaderIfAvailable set to false. * Fixed a bug in WebpageOperation that that resulted in a retain cycle. * - Refactored WebpageOperation as ComposedOperation to fix a retain cycle. - Added Documentation. * Fixed some typos in WebpageOperationTests. * Implemented OpenInSafariOperation (#317) * Implemented OpenInSafariOperation * Made the displayControllerFrom non optional. * Refactored OpenInSafariOperation. * Fixes a bug removing dependencies on Condition (#309) The issue is that ComposedCondition must remove the dependency on its composed condition too. * Improves cancellation checks in main() (#319) * [OPR-287]: Invokes observers in main main() is called from start, and we already check that the operation is not cancelled. Therefore the check at the start of main is redundant. However, we don't check after the observers have been executed that the operation is cancelled. * [OPR-287]: SwiftLint fixes. * Exposes LogSeverity enum to Objective-C (#324) * Remove Reachability from CloudKitOperation (#327) * Ignore DS_Store * Rip out reachability from CloudKitOperation * [OPR-327]: Adds trailing closure syntax * [OPR-327]: Adds TimeoutObserver * [OPR-327]: Adds tests for timeout observer * Override NSOperationQueue's mainQueue() (#330) * Override NSOperationQueue's mainQueue() to return the main queue as an OperationQueue * set maxConcurrentOperationCount to 1 * Adds missing functionality of UIAlertController to AlertOperation (#334) * Added missing functionality of UIAlertController to AlertOperation. * Annotated new functionality as public. * Added test cases for new functionality. * Made alert property of AlertOperation private. * SwiftLint corrections. * Added a test for preferredAction and fixed a but related to it. * Made UserIntent enum objc accessbile (#341) * Fixed network observer flickering (#338) Added tests for multiple operations having network observer * Supports error recovery in GroupOperation (#326) * [OPR-326]: Adds Errors subtype in Operation * [OPR-326]: Refactors GroupOperation willFinish API * Revert "[OPR-326]: Adds Errors subtype in Operation" This reverts commit 759f2ef3643cafbbda3544185234b8adeec474ef. * [OPR-326]: WIP on group operation errors * [OPR-326]: Fixes issues with retry operation tests This is still not quite right. * [OPR-326]: Allows RetryOperation to fully recover from errors * [OPR-326]: Fixes issue with tests * [OPR-326]: Tweaks ProfilerTest case * [OPR-326]: Refactors ComposedOperation to just subclass GroupOperation * [OPR-326]: Changes behaviour when a group produces an operation * [OPR-326]: Logs when a GroupOperation successfully recovers from errors * [OPR-326]: Logs when the next operation will be added * [OPR-326]: Adds an immediate WaitStrategy * [OPR-326]: Adds the operation to the log when attempting recovery * [OPR-326]: Removes unneeded handling of child errors * [OPR-326]: Allows the WaitStrategy to be defined at init * [OPR-326]: Changes to support ComposedOperation * [OPR-326]: Speeds up CloudKit tests with .Immediate wait strategy * [OPR-326]: WIP on GroupOperation errors * [OPR-326]: Fixes a bug where operation would not retry In the case where there is a default handler, but no custom one set for the same error. * [OPR-326]: Renames internal methods to be more Swifty * [OPR-326]: Fixes errors - whoops. * Always create CLLocationManager on the main queue (#321) * [OPR-321]: Creates CLLocationManager on the main thread Also makes it thread safe. * [OPR-321]: Refactors capability to use guard & early exit. * [OPR-321]: Creates CLLocationManager lazily on the main thread Refactors UserLocationOperation to not use generic at the same time * [OPR-321]: Fixes deadlock in creating CLLocationManager * [OPR-321]: Refactors location operations for early exit * [OPR-321]: Removes use of NSThread to check for main queue * [OPR-321]: Fixes a mistake with the merge * RepeatedOperation allows for configuration block to be reset by the payload (#348) * [OPR-332]: Adds support for RetryOperation to provide a configuration block * [OPR-332]: Removes commented out code * [OPR-332]: Adds test to check that configure block is replaced * Turns on Whole Module Optimization (#350) Fixes #349 * Exposes the UIAlert for customization. (#351) This also fixes a bug where it wasn't possible to set a barButtonItem on an ActionSheet while presenting as a popover. * Fixes OperationQueue.delegate crash (SR-192) (#353) * Add failing test test__SR_192_OperationQueue_delegate_weak_var_thread_safety: Tests race condition (and crash) involving OperationQueue’s weak delegate var. * Fix for OperationQueue.delegate crash (SR-192) The underlying error is in Swift < 3.0, with concurrent reads of weak properties. See: https://bugs.swift.org/browse/SR-192 This change wraps the public delegate property with an NSLock. It also sets it to nil first-thing in deinit to safely get rid of it. * Simplistic support for CKLimitExceeded error handling (#294) * [OPR-294]: Initial work adding built in support for CKLimitExceeded * [OPR-294]: Rewrite with support for nil response * [OPR-294]: Adds support for adding error handlers in bulk * [OPR-294]: Fixes some comments * [OPR-294]: Moves error handling to CloudKitError * [OPR-294]: Adds BatchProcessErrorType This is only needed for CKMarkNotificationsOperation * [OPR-294]: Renames error protocols * [OPR-294]: Adds support for batch processing * [OPR-294]: Adds & Refactors for tests * [OPR-294]: Minor tweaks * [OPR-294]: Further tweaks * [OPR-294]: Fixes error in bisect * [OPR-294]: Adds API to replace the configure block outright * [OPR-294]: Fixes failing tests * [OPR-294]: Refactors stress tests condition * Adds TaskOperation (#355) * [OPR-313]: Adds TaskOperation * [OPR-313]: Adds more test coverage * [OPR-313]: Adds header documentation * Vastly improves thread safety in Operations (#358) * FIX: GroupOperation.operations contains the initial operations twice after beginning to execute. Cause: `GroupOperation.execute()` calls `GroupOperation.addOperations(operations)`, which then re-adds the operations back to the operations array. Solution: Added a private **`_addOperations()`** method to `GroupOperation` with an additional flag to override this behavior - used in `GroupOperation.execute()`. `addOperations()` now calls this private implementation method. * Operation.cancel(), Operation.finish() thread-safety - `Operation.cancel()` now acquires the stateLock. - `Operation.finish()` now acquires the stateLock. - `stateLock` is now NSRecursiveLock(). - var `Operation.cancelled` is thread-safe. - var `Operation.errors` is thread-safe. - Explicitly send KVO notifications on NSOperation keyPaths at the right times, avoiding lots of unnecessary notifications. - Removed “State” KVO notifications. (Previously used to trigger NSOperation isExecuting/isFinished notifications, which are now triggered explicitly.) - Added missing operationWillFinish() call to finish(). - operationDidFinish() now happens after the state has been set to .Finished. - `Operation.cancelWithError(errors)` now asserts if it’s called while the Operation is finishing or finished. * Operation.main() thread-safety, Operation.disableAutomaticFinishing - `Operation.main()` acquires the stateLock when appropriate. - `Operation.main()` manually sends the isExecuting NSOperation KVO notifications when setting executing state. - Added ability to disable Operation’s automatic calling of finish(), with `init(disableAutomaticFinishing: Bool)`. (Defaults to existing behavior - i.e. false.) * GroupOperation improvements (finish and thread-safety) - GroupOperation should only finish() after its children have finished. - `GroupOperation._addOperations()` acquires the stateLock. - `GroupOperation._addOperations()` cancels new child operations if the GroupOperation is cancelled. * RepeatedOperation.addNextOperation() must check cancelled - RepeatedOperation.addNextOperation() now checks cancelled status. * Added new cancellation-related tests * Added new GroupOperation tests * Added Operation KVO notification tests (for NSOperation keyPaths) * Fixed spurious commit * Handle more possible cases in Operation.main() - Check that the Operation is not already executing. - Check that the Operation has not been finished by a WillExecute observer (either directly or as a side-effect of something else). Added a test case that demonstrates this possibility. * Add missing super.init() calls * More GroupOperation cancelling fixes - Changed the internal WillCancelObserver to a DidCancelObserver to ensure that the cancelled state has been set prior to cancelling child operations. (This ensures that side-effects of propagating cancellation to child operations - like RepeatedOperation attempting to add the next operation - can safely check the cancelled status.) * GroupOperation should not call queue.cancelAllOperations() Calling queue.cancelAllOperations() also cancels the finishingOperation, which skips properly waiting until all other child operations are finished. Fixed test. * Added willProduceOperation method to OperationQueueDelegate, fix GroupOperation handling of child-produced operations Informational method only. This enables GroupOperation to add child-produced operations to its internal operations array, and thus cancel them when the GroupOperation is cancelled. Added tests. * GroupOperation should ignore queue delegate calls from other queues Added missing guard at the top of the queue delegate methods in GroupOperation. Added test to illustrate simple failure case this change covers. * Refactor lock usage in Operation.finish() and .cancel() - Refactor lock usage to hold the stateLock only when necessary or manipulating internal state, and *not* when sending KVO notifications or notifying observers. - Improvements and fixes to KVO Notification Tests. * Further refactor lock usage in Operation (.execute()) - Refactor lock usage in `Operation.execute()` to hold the stateLock only when necessary or manipulating internal state, and *not* when sending KVO notifications or notifying observers. * Add a number of new StressTests that previously failed/crashed New tests have support for a `batches` parameter. * Initial fix for Logging-related crashes (thread-safety issues) - `Operation._log` must not be a lazy var. From the Swift book: > If a property marked with the lazy modifier is accessed by multiple threads simultaneously and the property has not yet been initialized, there is no guarantee that the property will be initialized only once. For more: https://bugs.swift.org/browse/SR-1042 - `Operation.log` must be thread-safe. Initial fix involves capturing a copy of the logging context (settings + operationName) at the time of access of `Operation.log`, returning that captured context as a LoggerType, and surrounding access of .log with a Read/Write lock. - LogManager properties must be thread-safe. * Refactor lock usage in GroupOperation - var `GroupOperation.operations` is now thread-safe. - GroupOperation now utilizes a private CanFinishOperation to safely transition to executing the finishingOperation. (See code & comments.) - GroupOperation now has its own lock that is used sparingly to protect finishing state. - `GroupOperation._addOperation()` now utilizes the groupFinishLock. * Minor tweaks - `Operation.stateLock` should remain private. * SwiftLint clean-up * Refactor lock usage in GroupOperation - Refactor lock usage to hold the groupFinishLock only when necessary or manipulating internal state, and *not* when sending KVO notifications, notifying observers, or changing additionalOperations state (which might send KVO notifications or notify observers). * Clean-up - Remove asserts from `Operation.cancelWithErrors()`. Operation cancellation methods should be safe to call at any time without asserting. - Other minor tweaks. * Clean-up - Moved NSOperationKeyPaths to extension NSOperation.KeyPath enum. * Clean-up * Clean-up - Remove unneeded `self.` * Clean-up * Clarify docs & re-formatting * Add new inits to Queue (NSQualityOfService and qos_class_t) Per code review. * Clean-up of GroupOperation * Make Operation.cancel() final (#359) Per discussion in: https://github.com/danthorpe/Operations/pull/293 https://github.com/danthorpe/Operations/pull/358#discussion_r70167086 * Supports composing simple types for Result injection (#362) * [OPR-362]: Linting whitespace changes * [OPR-362]: Adds support for composing “executors” inside a final Operation type This is a convenience class to aid adoption of _Operations_ without requiring types to subclass Operation. Instead, classes only need to conform to Executor, and then can use the Execute class, which support cancellation, and result injection. * Supports async executors (#363) * Fixes a finished log message (#365) The "Operation Did finish" log was using the opposite logic for error logging * Group's internal queue is non-public; exposes appropriate properties (#361) * Make GroupOperation's internal queue non-public, and expose appropriate properties on GroupOperation - Make GroupOperation.queue ~private~internal. (So it can be tested.) - Expose appropriate run-time editable properties of the GroupOperation’s queue as properties on GroupOperation. Specifically: - public var maxConcurrentOperationCount: Int - public var suspended: Bool - public var qualityOfService: NSQualityOfService - Add tests. * [OPR-361]: Support underlying queue in Group * GatedOperation cancels composed operation when gate is closed (#377) * [OPR-377]: Adds early exit with guard * [OPR-377]: Refactors GatedOperation execute * [OPR-377]: Fixes typo * Result Injection protocol improvements (#378) * [OPR-378]: Updates result injection APIs * [OPR-378]: Adds unit tests * [OPR-378]: Removes unnecessary weak self capture * Fixes dependency gets added twice if it's direct & indirect (#379) * [OPR-379]: Adds a failing unit test * [OPR-379]: Makes indirect dependencies unique set * Removes TaskOperation from non-macOS platforms (#382) * Removes AlertPresentation mutual exclusion (#383) * Adds IgnoredCondition (#385) * Filters out indirect dependencies which have already been added (#386) * Fixes issues with ignored condition (#390) This means that conditions which are ignored mean that the attached operation does not execute, but also does not finish with an error. It’s a nicer use case than GatedOperation. This works by checking the OperationResult for .Ignored and then only cancel() instead of cancelWithError(). Note that if the operation also has .Failed(errors) condition result, in addition to .Ignored then the operation will still not run but this time with errors (as expected). Note that if the operation also has .Satisfied condition result, in addition to .Ignored then the operation will not run, but without errors. * NoFailedDependenciesCondition supports ignoring cancelled operations (#397) Fixes #396. * [OPR-396]: NoFailedDependenciesCondition support ignoring cancels * [OPR-396]: Refactors initializer * [OPR-396]: Renames the condition * Ability to add configuration to the next (retried) CloudKitOperation (#395) * Adds CloudKitOperation.setPrepareForRetryHandler() * Adds BatchedCloudKitOperation.setPrepareForNextOperationHandler() * Clean-up * Updated new APIs, added documentation -Simpler, cleaner, better APIs. -Added documentation and examples for the new APIs. * Add documentation for BatchedCloudKitOperation. * Updates project header (#399) * [OPR-399]: Updates the header * [OPR-399]: Updates the README to point to the new URL for header * Updates guidelines (#400) * [OPR-400]: Updates copyright holders to “ProcedureKit” * [OPR-400]: Adds a code of conduct * [OPR-400]: Fixes a markdown formatting issue * [OPR-400]: Adds CONTRIBUTING guidelines * [OPR-400]: Moves CONTRIBUTING to .github directory * [OPR-400]: Removes an empty section * [OPR-400]: Adds instruction on adding verbose logs. * [OPR-400]: Updates CONTRIBUTING guideline * [OPR-400]: Updates README too * [OPR-400]: Fixes some typos * Creates ProcedureKit project (#401) * [OPR-401]: Sets up ProcedureKit project * [OPR-401]: Adds ProcedureKitMobile This will cover iOS & watchOS * [OPR-401]: Adds ProcedureKitTV * [OPR-401]: Fixes Runtime Search Paths * [OPR-401]: Adds StressTests * [OPR-401]: Adds ProcedureKitMac * [OPR-401]: Enables code coverage on all testable schemes * [OPR-401]: Adds ProcedureKitCloud * [OPR-401]: Changes to module imports * [OPR-401]: Changes Cloud to latest deployment versions * ProcedureKit CI - Stage 1 (#403) * [OPR-403]: Changes Stress Tests to only run as part of the ProcedureKitMac scheme * [OPR-403]: Changes Cloud minimum target versions * [OPR-403]: Adds tests to CI - ProcedureKit macOS * [OPR-403]: Fixes Operations mac tests * [OPR-403]: Fixes Operations tests 2 * [OPR-403]: Fixes Swift version to 2.2 * [OPR-403]: Moves common scripts around * [OPR-403]: Updates scripts * [OPR-403]: Changes to the Fastlane name for mac * [OPR-403]: Updates build dependencies * [OPR-403]: Sets the correct destination platform * [OPR-403]: Updates scan invocation * [OPR-403]: Updates Fastfile * [OPR-403]: Trying to use which to find bundle * [OPR-403]: Using quotes * [OPR-403]: Adds setup first * [OPR-403]: Putting the whole setup into quotes * [OPR-403]: Attempting to add multiple lines to the command * [OPR-403]: Puts it all on one line * [OPR-403]: Adds more ProcedureKit steps * [OPR-403]: Fixes error in Stress Tests build settings * [OPR-403]: Pipline Uploads * [OPR-403]: Fixes pipelines * [OPR-403]: Uses pipeline upload correctly * [OPR-403]: Fixes error in mobile tests * [OPR-403]: Adds watchOS * [OPR-403]: Removes automatic code signing * [OPR-403]: Comments out watchOS builds * [OPR-403]: Adds TV * [OPR-403]: Removes ad-hoc code signing * [OPR-403]: Fixes Operations iOS * [OPR-403]: Sets iPhone Developer automatic code signing * [OPR-403]: Updates buildkite agent tags for iOS Simulator * [OPR-403]: Sets the development team in xcargs * [OPR-403]: Enables automatic code signing without a team set * [OPR-403]: Fixes issues with code signing settings for TV * [OPR-403]: Removes the development team * [OPR-403]: Puts everything into a single pipeline * [OPR-403]: Cleans up the pipeline * [OPR-403]: Sets personal team for mobile unit tests * [OPR-403]: Updates the Fastlane lane names * [OPR-403]: Adds a copy frameworks build phase * [OPR-403]: Removes copy files phase * [OPR-403]: Comments out problematic build jobs * [OPR-403]: Removes Operations CI jobs * ProcedureKit CI - Stage 2 (#404) * Update CI dependencies (#409) * [OPR-409]: Updates dependencies and enables pipeline * [OPR-409]: Fixes YML * [OPR-409]: Fully specifies the destination Starting to really not like Fastlane * [OPR-409]: Switches to iOS 10 simulators. * [OR-409]: Sets the developer directory * [OPR-409]: Removes tvOS for Mobile framework * [OPR-409]: Reorders the jobs * Add base types to ProcedureKit (#405) * [OPR-405]: Creates Procedure * [OPR-405]: Sets the Swift version * [OPR-405]: Cleans project * [OPR-405]: Changes to destination * [OPR-405]: Stops using Fastlane for testing macOS * [OPR-405]: Adds initial files for ProcedureQueue * [OPR-405]: Defines ProcedureObserver * [OPR-405]: Adds the default implementation of ProcedureObserver * [OPR-405]: Adds the rest of the observer protocols * [OPR-405]: Adds @available annotations * [OPR-405]: Adds block based observers * [OPR-405]: Adds Protector / DispatchQueue extension * [OPR-405]: Further updates to observers API * [OPR-405]: Adds extension to Operation This is for addCompletionBlock - but will be used for more stuff when we get into dependencies * [OPR-405]: Fixes lint issues * [OPR-405]: Adds Procedure protocol with AbstractProcedure * [OPR-405]: Starts interfaces in AbstractProcedure for execute & finish * [OPR-405]: Adds state transition * [OPR-405]: Refactors Procedure to be protocol based. * [OPR-405]: Adds most of the cancellaton functionality * [OPR-405]: Adds main implementation With a few TODOs * [OPR-405]: Fixes available renames * [OPR-405]: Changes AbstractProcedure back to Procedure * [OPR-405]: Adds Testing framework With TestProcedure class * [OPR-405]: Adds basic API to ProcedureTestCase * [OPR-405]: Updates dependencies * [OPR-405]: Commenting out non mac unit tests Run CI on iOS Simulators is basically impossible on beta version of Xcode. * [OPR-405]: Adds finishing and cancellation tests * [OPR-405]: Adds some finishing tests * Adds Logging (#428) * [OPR-428]: Adds LogSeverity * [OPR-428]: Adds logger * [OPR-428]: Updates logging stuff * [OPR-428]: Adds logging tests * Group (#430) * [OPR-430]: Adds Group * [OPR-430]: Adds initializers to Group * [OPR-430]: Adds add child API to Group * [OPR-430]: Corrects spelling * [OPR-430]: Adds finishing APIs to Group * [OPR-430]: Adds extension of unavailable APIs * [OPR-430]: Adds GroupObserverProtocol * [OPR-430]: Adds error handling and recovery to Group * [OPR-430]: Improves group observers API * [OPR-430]: Adds first group test * [OPR-430]: Adds some basic tests for Group * [OPR-430]: Adds more unit test for Group * [OPR-430]: More tests for group * Adds User Intent (#439) * [OPR-439]: Adds UserIntent to Procedure * [OPR-439]: Adds userIntent to Group * Stress Tests Phase 1 (#442) * [OPR-442]: Adds StressTestCase and completion block stress tests * [OPR-442]: Uses StressLevel directly. * [OPR-442]: Refactors the test case names * [OPR-442]: Refactors to remove StressTestCase Instead the stress function can be added to the base ProcedureKitTestCase * [OPR-442]: Adds group cancel stress test * [OPR-422]: Refactors group stress tests These are currently failing * [OPR-422]: Refactors schemes, as stress tests are run as part of Mac tests * [OPR-442]: Updates Stress Tests batches Uses intermediate BatchProtocol, and exposes a measure API. * [OPR-422]: Changes the active developer directory * [OPR-422]: Adds group child finishing order stress test * [OPR-422]: Fixes incorrect pipeline step * [OPR-422]: Adds more stress tests for Procedure * [OPR-422]: Fixes TestError mistake * [OPR-422]: Changes to use didCancelBlockObserver Instead of didFinishBlockObserver - there might be a subtle bug here. * [OPR-422]: Disables some checks - have identified that there is definitely an error in finishing logic * [OPR-422]: Moves stress tests to their own scheme * [OPR-422]: Adds stress fastlane * [OPR-422]: Trying to see how to trigger stress tests * [OPR-422]: Removing - * [OPR-422]: Changes the trigger to ProcedureKit * [OPR-422]: Add the pipeline update step back * [OPR-422]: Fixes yml * [OPR-422]: More changes to pipeline template * [OPR-422]: Fixes the slug This is case sensitive! * [OPR-422]: Triggers a different pipeline stress tests * [OPR-422]: Adds commit message to stress test build * [OPR-422]: Modifies measure to be a little quicker * [OPR-422]: Updates baselines with Mac Pro * [OPR-422]: Fixes mistake with finishing from cancel * Fix issue with newlines in pipeline upload (#445) * [OPR-445]: Removes message from upload script * [OPR-422]: Puts the commit back * Initial work on Result Injection (#446) * Adds Dependencies & Conditions (#429) * [OPR-429]: Adds Condition protocol and class * [OPR-429]: Adds conditions to procedure and queue * [OPR-429]: Adds tests for Conditions Also adds XCTAssertProcedure functions to make verifying Procedure behaviour more consistent. * [OPR-429]: Adds remaining unit tests for conditions Still got Ignored Condition to add * [OPR-429]: Fixes some documentation * [OPR-429]: Performs the stress tests in the same build * [OPR-422]: Adds stress tests for conditions * [OPR-429]: Adds IgnoredCondition * ProcedureKitError (#437) * [OPR-437]: Regorganized the Core group * [OPR-437]: Refactors Errors into ProcedureKitError * Completes Result Injection API test coverage (#447) * [OPR-447]: Sorts out ResultInjection * [OPR-447]: Completes result injection tests * Fixes Xcode 8 GM issues (#463) * BlockProcedure (#450) * [OPR-450]: Adds BlockProcedure * [OPR-450]: Adds unit tests for map and block procedures * [OPR-450]: Adds some stress tests for block procedure * [OPR-450]: Updates stress tests * [OPR-450]: Fixes Xcode 8 GM escaping issue * [OPR-450]: Papers over some possible issues with finishing. In many cases the `should finish after cancelling` logic is returning false. * [OPR-450]: Removes some excessive logging * [OPR-450]: Adjusts variation to 15% * Mutual exclusive conditions (#448) * [OPR-448]: Adds MutualExclusion * [OPR-448]: Adds support for adding dependencies for mutual exclusion * [OPR-448]: WIP on mutual exclusivity * [OPR-448]: Finishes off test cases for mutual exclusivity * [OPR-448]: Refactors add condition API to attach condition I want to make the API consistent - but not choose consistency over intent. So, `add(dependency: myDependency)` makes sense - as it signals that the dependency is already managed by some other queue/system. Where as for a Condition, we specifically _attach_ it to Procedure instance, and it does not (ideally should not) be managed outside the Procedure. So, I want the concept of “attaching conditions to procedures” to be the language which is used to describe the behaviour. * DelayProcedure (#449) * [OPR-449]: Adds delay procedure * [OPR-449]: Adds DelayProcedure tests * Renames Group to GroupProcedure (#468) * Adds ProcedureKit.podspec (#467) * Adds NegatedCondition (#471) * Adds SilentCondition (#472) * Procedure finishing fixes (#474) * Resolve finishing issues related to FinishingFrom. * Add StressTest that covers concurrent calls to finish() * Revert ProcedureKitTestCase expectation fulfillment back to the main queue. * Adds BlockCondition (#473) * Adds NoFailedDependenciesCondition (#470) * Adds TimeoutObserver (#475) * [OPR-475]: Adds TimeoutObserver * [OPR-475]: Fixes issues with TestProcedure It was not correctly delaying. * Procedure name and identity (#478) * [OPR-478]: Adds name and Identity * [OPR-478]: Fixes some failing tests * [OPR-478]: Fixes another failing name test * Adds BlockObserver (#480) * [OPR-480]: Adds BlockObserver * [OPR-480]: Tweaks to stress tests * Adds ComposedProcedure & GatedProcedure (#487) * RepeatProcedure (#488) * [OPR-488]: Initial work on RepeatProcedure * [OPR-488]: Adds remaining test coverage * RetryProcedure (#491) * [OPR-491]: Adds RetryProcedure * [OPR-491]: Unifies the generic init pattern for repeat and retry procedures * Adds support for Capabilities (#492) * [OPR-492]: Fixes incorrectly spelt protocol * [OPR-492]: Adds Capability Including CapabilityProtocol, GetAuthorizationStatus, Authorize, AuthorizedFor * Adds BackgroundObserver (#476) * [OPR-476]: Fixes stress tests * [OPR-476]: Adds BackgroundObserver * [OPR-476]: Gets the Mobile test suite working * [OPR-476]: Switches code coverage on * [OPR-476]: Adds missing callback This was causing a failing unit test * [OPR-476]: Removes unnecessary build phase * [OPR-476]: Finishes BackgroundObserver tests * [OPR-476]: Removes verbose logging in test case * Adds FilterProcedure (#496) * [OPR-496]: Adds FilterProcedure * [OPR-496]: Adds filter method for when Result is a sequence * Adds ReduceProcedure (#497) * [OPR-497]: Adds ReduceProcedure * [OPR-497]: Refactors Map, Filter adds FlatMap MapProcedure is really a TransformProcedure. MapProcedure and FilterProcedure are now simple subclasses of ReduceProcedure, along with FlatMapProcedure. * Adds NetworkObserver (#498) * [OPR-498]: Adds NetworkObserver Additionally, this updated ProcedureKitTestCase to automatically add async expectation fulfills around operations which might be produced by a procedure. * [OPR-498]: Refactors ProcedureKitTestCase slightly for Swift 3 conventions. * Adds Location.Capability (#499) * [OPR-499]: Adds ProcedureKitLocation framework * [OPR-499]: Supports sychronous dispatch onto the main queue This is safe to call if already on the main queue. * [OPR-499]: Adds Capability.Location * Adds UserLocationProcedure (#500) * [OPR-500]: Adds UserLocationProcedure * [OPR-500]: Removes unneeded error struct * [OPR-500]: Fixes issue with tvOS * Corrects minimum deployment targets (#503) Fixes #501 * [OPR-501]: Fixes issues with deployment versions * [OPR-501]: Setting tvOS to 9.2 * Adds ReverseGeocodeProcedure (#502) * [OPR-502]: Adds ReverseGeocodeProcedure * [OPR-502]: Adds ProcedureKitMobile as a build dependency * [OPR-502]: Fixes a mistake where macOS location tests were requiring iOS simulator * [OPR-502]: Uses gym to ensure iOS builds ProcedureKitMobile before testing Location * [OPR-502]: Use scan instead of gym This is a hack. I want to make sure that when we test ProcedureKitLocation on iOS we have build ProcedureKitMobile. * Adds ReverseGeocodeUserLocationProcedure (#504) * [OPR-504]: Adds/renames files * [OPR-504]: Adds ReverseGeocodeUserLocationProcedure * [OPR-504]: Rounds out the unit tests on ReverseGeocodeUserLocationProcedure * Makes procedures open where appropriate (#510) * Refactors BlockProcedure (#511) * Adds AnyProcedure (#516) * [OPR-516]: Removes import foundation This is done by the prefix header * [OPR-516]: Adds AnyProcedure * [OPR-516]: Uses the correct underlying queue throughout AnyProcedure * Fixes regression of failing release build (#518) * Renames AuthorizationStatusProtocol to AuthorizationStatus (#519) * Renames capability reated procedures (#520) * Renames attach(condition: Condition) to add (#521) * Adds Capability.CloudKit (#523) * [OPR-523]: Adds Capability.CloudKit * [OPR-523]: Enables CI builds for CloudKit stuff on iOS and tvOS * Adds ProcedureKitNetwork framework (#524) * [OPR-524]: Adds ProcedureKitNetwork framework * [OPR-524]: Adds Network to CI jobs * [OPR-524]: Renames Stress Tests job * [OPR-524]: Shares the network scheme * [OPR-524]: Imports Foundation instead of Cocoa * [OPR-524]: Forces Stress Tests onto a non-simulator agent * Adds NetworkDataProcedure (#525) * [OPR-525]: Adds NetworkDataProcedure * [OPR-525]: Fixes up some unit tests * [OPR-525]: Adds missing test coverage * Moves TestableNetwork into TestingProcedureKit framework (#526) * Refactors injectDependency API to be an extension on ProcedureProtocol instead. (#527) * Adds transform block result injection API (#528) * [OPR-528]: Refactors result injection Uses an intermediatory injectResult(from: via:) API, which allows the caller to provide a throwing block to transform the result into the requirement. * [OPR-528]: Removes unneeded return * [OPR-528]: Fixes error in ProcedureKitLocation * Adds default empty implementations some queue delegate methods (#531) Only added the will-do-something ones. Fixes #530 * Adds space in the repo for presentations (#533) * [OPR-533]: Adds CocoaHeads Stockholm talk Contact @danthorpe if you want the original Keynote file. * [OPR-533]: Adds Sky-UK iOS Community Talk * [OPR-533]: Adds a presentations README * Disables the log for AnyProcedure (#534) * Fixes bug where GroupProcedure collects errors from children after its been cancelled (#532) * [OPR-532]: Adds failing test * [OPR-532]: Checks cancelled state of the group We can exit this delegate callback early if the group has already been cancelled. * [OPR-532]: Removes default implementation of willFinish It seems that adding default implementations here causes some odd behaviour / intermittent crash where this is overwritten in the QueueDelegate. * [OPR-532]: Fixes a unit test which is now mis-counting errors. * Adds .then { } API (#536) * [OPR-176]: Adds then extension on Operation * [OPR-176]: Implements .then { } API * [OPR-176]: Adds enqueue method to a collection of Operations * [OPR-176]: Fixes header docs * Removes default argument for session in NetworkDataProcedure (#538) * Tweaks the cancel block procedure stress tests (#539) There might be an underlying issue. As normally a batch of 10_000 finishing in ~ 5 seconds. But sometimes fails because it times out, meaning that an expectation is not getting fulfilled. * Moves ProcedureKit imports to umbrella headers (#540) * [OPR-540]: Putting the appropriate imports into umbrella headers * [OPR-540]: Fixing issues with importing ProcedureKit into TestingProcedureKit * Updates ProcedureKit podspec with subspecs (#508) * [OPR-508]: Lints podspec without an warnings or errors. * [OPR-508]: Fixes errors running tests * Adds ResilientNetworkProcedure (#537) * [OPR-537] Adds ResilientNetworkProcedure * [OPR-537]: Updates retry request with error code * [OPR-537]: Adds edge case for ResilientNetworkProcedure In some situations, the HTTP status code might well require (depending on the behaviour) a retry. * [OPR-537]: Fixes simple unit tests * Refactor ResultInjection to use PendingValue enum (#541) * [OPR-541]: Refactors ResultInjectionProtocol to use PendingValue enum * [OPR-541]: Renames ResultInjectionProtocol to ResultInjection * Fixes BlockProcedure stress tests (#544) * [OPR-544]: Fix test__cancel_block_procedure() failures It was possible for the testing BlockProcedure to finish prior to the `block.cancel()` call, which would result in some of the BlockProcedures never cancelling (as they had finished first), and a failing test. Fixed by using a semaphore inside the BlockProcedure’s block. Additionally, the test now waits for all BlockProcedures to cancel *and* finish. * [OPR-544]: Added a new stress test for BlockProcedure cancelling & finishing behavior (allowing for possible races between cancelling and finishing) * Fixes ExclusivityManager synchronization bug (#545) Fixes #543 The ExclusivityManager was using `DispatchQueue.initiated`, which returns a global **concurrent** queue, however its internals are dependent upon **serial** execution of add/remove. Modified to use a serial queue. * Adds ResultProcedure and overloads injectResult(from:) (#546) * Adds HTTPResult<Payload> (#547) * Fix test crashes caused by QueueTestDelegate (#549) QueueTestDelegate was not thread-safe. This could result in crashes running random tests. Fixed by making QueueTestDelegate’s methods thread-safe. * Adds ProcedureKitTestCase wait function that takes an array (#552) * Adds TestingProcedureKit podspec (#553) * Adds Mutual Exclusivity concurrency testing (#550) * Add ConcurrencyTestCase Exposes functionality to test operation concurrency. * Add Mutual Exclusivity concurrency tests * Refactored ConcurrencyTestCase * Refactored ConcurrencyTestCase * Adds didExecuteObserver (#554) * [OPR-554]: Adds code with failing test * [OPR-554]: Calls didExecuteObservers * [OPR-554]: Fixes a typo * [OPR-554]: Adds some documentation to the DidExecuteObserver * Fixes mistake in Fastfile (#557) * [OPR-557]: Fixes error in Fastfile * [OPR-557]: Removes duplicate scan I remember now, as part of location, we used to build Mobile too - because there was a dependency on iOS. But this has since been removed. * Fixes release configuration issues with Xcode 8.1 (#559) Fixes #548 * [OPR-548]: Fixes issue with Xcode 8.1 release configuration * [OPR-548]: Fixes some SwiftLint warnings. * [OPR-548]: Fixes Xcode project warnings in Xcode 8.1 * Adds GroupProcedure concurrency tests (#556) * Add GroupConcurrencyTestCase * Add GroupProcedure.maxConcurrentOperationCount tests * Fixes registrar typo (#562) * Adds NetworkDownloadProcedure. (#565) The implementation for class and test is largely inspired by `NetworkDataProcedure` class. * Adds NetworkUploadProcedure. (#567) * Add NetworkUploadProcedure. The implementation class and test has been largely inspired by `NetworkDataProcedure`. The requirement type is currently a pending value of a tuple. Maybe would it make more sense to create a dedicated struct to add more clarity in the case of dependencies injection ? * Use an `HTTPRequirement` struct for requirement. As discussed, an `HTTPRequirement` struct is used instead of a tuple. * Fixes Condition to support ResultInjection (#566) * [OPR-566]: Replaces Condition result with PendingValue<ConditionResult> * [OPR-566]: Refactors how conditions are evaluated This fixes a existing issue where the ConditionEvaluation enum was basically just like ConditonResult, except that it could hold an array of errors. This has been resolved by using an internal error type `ProcedureKitError.FailedConditions` to collect multiple errors from failed conditons, so that we can reduce a sequence of `ConditionResult`s into a single one. * [OPR-566]: Explicitly adds a Result typealias * [OPR-566]: Fixes error where cancelled conditions would throw a fatal error. * [OPR-566]: Removes verbose log * Adds ProcessProcedure. (#570) * Add ProcessProcedure. The class has been largely inspired by the original `TaskOperation`. Refers to #568. * Apply requested changes. Correctly implement `Equatable` for sub-error enum. Use camel case for the enum. Fix closure self semantics. * Calls TestableReverseGeocoder completionHandler on the main queue (#572) * Improves performance of adding observers * Procedure.add(observer:) performance tweak Append directly to the protected observers array. * Fix swiftlint `variable_name` warning * Makes ProcedureQueue.add(operation: Operation) method open (#578) * Fixes NetworkObserver thread-safety (#576) (#577) * Fix NetworkObserver thread-safety By fixing NetworkActivityController `start()`/`stop()` thread-safety. (And making private methods/variables private.) * NetworkObserver test fixes * Reduce test delay * Additional GroupProcedure tests (#579) * Adds CloudKitProcedure (#542) * [OPR-542]: Adds shell of CloudKit files * [OPR-542]: Adds extensions for CKOperation * [OPR-542]: Adds extensions for CKDatabaseOperation * [OPR-542]: Adds extensions for CKAcceptSharesOperation * [OPR-542]: Adds extensions for CKDiscoverAllContactsOperation * [OPR-542]: Adds extensions for CKDiscoverAllUserIdentifiesOperation * [OPR-542]: Adds extensions for CKDiscoverUserIdentitiesOperation * [OPR-542]: Adds extensions for CKDiscoverUserInfosOperation * [OPR-542]: Adds extensions for CKFetchDatabaseChanges * [OPR-542]: Adds extensions for CKFetchDatabaseChangesOperation * [OPR-542]: Adds extensions for CKFetchRecordChangesOperation * [OPR-542]: Moves the interface into the extension files * [OPR-542]: Fixes dispatchQueue * [OPR-542]: Adds extensions to CKFetchRecordsOperation * [OPR-542]: Adds extensions for CKFetchRecordZoneChangesOperation * [OPR-542]: Removes unnecessary public properties * [OPR-542]: Adds extensions for CKFetchRecordZonesOperation * [OPR-542]: Adds extensions for CKFetchShareMetadataOperation * [OPR-542]: Adds extensions for CKFetchShareParticipantsOperation * [OPR-542]: Adds extensions for CKFetchSubscriptionsOperation * [OPR-542]: Adds extensions for CKMarkNotificationsReadOperation * [OPR-542]: Adds extensions for CKModifyBadgeOperation * [OPR-542]: Adds extensions for CKModifyRecordsOperation * [OPR-542]: Adds extensions for CKModifyRecordZonesOperation * [OPR-542]: Adds extensions for CKModifySubscriptionsOperation * [OPR-542]: Adds extensions for CKQueryOperation * [OPR-542]: Adds missing APIs for error handlers * [OPR-542]: Adds testable CK operation classes * [OPR-542]: Adds tests for CKOperation, CKDatabaseOperation and CKAcceptSharesOperation * [OPR-542]: Removes missing test cases from tvOS * Small typo fix * Adds tests for CKDiscoverAllContactsOperation * Adds tests for CKDiscoverAllUserIdentitiesOperation * Adds tests for CKDiscoverUserIdentitiesOperation * Adds tests for CKDiscoverUserInfosOperation * [OPR-542]: Adds tests for CKFetchAllChanges protocol * [OPR-542]: Adds tests for CKFetchDatabaseChangesOperation * [OPR-542]: Adds tests for CKFetchNotificationChangesOperation * [OPR-542]: Adds tests for CKFetchRecordChangesOperation * [OPR-542]: Adds tests for CKFetchRecordsOperation * [OPR-542]: Added missing `recordZoneFetchCompletionBlock` for CKFetchRecordZoneChangesOperationProtocol extensions * [OPR-542]: Adds tests for CKFetchRecordZoneChangesOperation * [OPR-542]: Adds tests for CKFetchRecordZonesOperation * [OPR-542]: Adds tests for CKFetchShareMetadataOperation * [OPR-542]: Adds tests for CKFetchShareParticipantsOperation * [OPR-542]: Adds tests for CKFetchSubscriptionsOperation * [OPR-542]: Minor typo fix To follow the original API naming, change `setMarkNotificationReadCompletionBlock` to `setMarkNotificationsReadCompletionBlock`. * [OPR-542]: Adds tests for CKMarkNotificationsReadOperation * [OPR-542]: Adds tests for CKModifyBadgeOperation * [OPR-542]: Adds tests for CKModifyRecordsOperation * [OPR-542]: Adds tests for CKModifyRecordZonesOperation * [OPR-542]: Adds tests for CKModifySubscriptionsOperation * [OPR-542]: Adds tests for CKQueryOperation * [OPR-542]: Fixes whitespace in test cases * [OPR-542]: Adds CloudKitProcedure<CKAcceptSharesOperation> tests * [OPR-542]: Fixes tests on tvOS. Again. * [OPR-542]: Adds tests for CKDiscoverAllContactsOperation * [OPR-542]: Adds tests for CKDiscoverAllUserIdentitiesOperation * [OPR-542]: Adds tests for CKDiscoverUserIdentitiesOperation * [OPR-542]: Adds tests for CKDiscoverUserInfosOperations * [OPR-542]: Adds tests for CKFetchDatabaseChangesOperation * [OPR-542]: Unifies testing of common properites * [OPR-542]: Adds tests for CKFetchNotificationChangesOperation * [OPR-542]: Adds tests for CKFetchRecordChangesOperation * [OPR-542]: Adds test for CKFetchRecordsOperation * [OPR-542]: Adds tests for CKFetchRecordZoneChangesOperation * [OPR-542]: Adds test for CKFetchRecordZonesOperation * [OPR-542]: Adds tests for CKFetchShareMetadataOperation * [OPR-542]: Adds tests for CKFetchShareParticipantsOperation * [OPR-542]: Fixes inconsistently named tests * [OPR-542]: Adds tests for CKFetchSubscriptionsOperation * [OPR-542]: Adds tests for CKMarkNotificationsReadOperation * [OPR-542]: Adds tests for CKModifyBadgeOperation * [OPR-542]: Adds tests for CKModifyRecordsOperation * [OPR-542]: Adds tests for CKModifyRecordZonesOperation * [OPR-542]: Adds test for CKModifySubscriptionsOperation * [OPR-542]: Adds test for CKQueryOperation * [OPR-542]: Adds tests which trigger default retry behavior * [OPR-542]: Adds tests for set/get all errors handlers * [OPR-542]: Adds tests for custom error handlers * Adds Profiler (#573) * Implement Profiler as specified in #569. The implmentation is largely inspired by the original `Profiler.swift` file. * Add first set of tests. The test has been largely inspired by the original tests classes. I have a commented test taht fails. After trying to debug for a while, I suspect maybe an issue inside GroupProcedure or the original implementation. * Apply requested changes. Perform changes as requested. * Adds public initialiser to HTTPRequirement (#586) Declaring a constructor for the `HTTPRequirement` allows the construction of the struct without any issue. * Removes GroupProcedureObserver protocol (#583) Instead ProcedureObserver takes over this responsibility. * [OPR-574]: Cleans up white space & style for consistency * [OPR-574]: Uncomments failing test * [OPR-574]: Adds new API to ProcedureObserver protocol * [OPR-574]: Removes temporary print statements * [OPR-574]: Refactors to support willAdd & didAdd observer callbacks. * [OPR-574]: Removes commented out line. * [OPR-574]: Removes group observers. * [OPR-574]: Removes extraneous logging in some tests * [OPR-574]: Makes add(observer:) open for overriding * [OPR-574]: Adds some documentation comments to public interfaces * Supports Arbitrary mutual exclusion category names (#587) Fixes #580. * [OPR-580]: Supports arbitrary mutual exclusion category names * [OPR-580]: Fixes default category for AuthorizedFor * Adds NetworkReachableProcedure (#563) * [OPR-563]: Adds Reachability functionality * [OPR-563]: Adds additional files for testing support * [OPR-563]: Adds tests for Reachability * [OPR-563]: Adds basis of NetworkReachableProcedure * [OPR-563]: Adds simple network reachability procedure tests * [OPR-563]: Fixes issue with Protector write being synchronous. * [OPR-563]: Refactors DeviceReachability slightly * [OPR-563]: Changes Protector behavior back to be non-blocking * [OPR-563]: Fixes Reachability.Device * [OPR-563]: Adds NetworkProcedure and ProcedureKitNetworkError * [OPR-563]: Fixes for network error tests * [OPR-563]: Adds remaining tests for Reachable procedure * [OPR-563]: Removes unnecessary logging * Refactors produce API (#588) * Add failing test * Test tweaks * Changes to Procedure.produce(operation:) handling Fixes failing test case, and simplifies execution flow. Changes `willEnqueue()` to `willEnqueue(on: ProcedureQueue)`. `func produce(operation: Operation)` now throws. * Ported additional test case from Operations 3.x. * swiftlint tweak * Fixed mobile tests. * Adds missing equality cases for ProcedureKitError.Context (#591) Fixes #589 * Supports merging collections of ResultInjection Procedures (#593) * [OPR-593]: Adds gather and reduce APIs * [OPR-593]: Removes the rethrows While the nextPartialResult closure can throw, this error is not re-thrown. Instead, because this block is executed after the receiver’s procedures have all finished, the error means that the `ResultProcedure` will finish with an error. * [OPR-593]: Adds test case for throwing closure * [OPR-593]: Refactors gather() so that it is a specialization of new flatMap API * Improves how stress tests are run in CI (#594) * [OPR-594]: Updates pipeline queues * [OPR-594]: Fixes yaml * [OPR-594]: Disables Thread Sanitizer for Stress Tests * [OPR-594]: Uses Release configuration for stress tests * Fix StressTestCase Batch counters thread-safety (#555) (#596) * Fixes public access levels for CKProcedure (#599) * Fixes some RepeatProcedure thread-safety issues (#597) Fix issues identified by an audit and Thread Sanitizer * Fixes Procedure & Support thread-safety (#598) * Change Protector.write() to be synchronous (and optionally return a value from the block) Thread Sanitizer identified a data race caused by the combination of the prior asynchronous `write()` and deinitialization. * Explicitly `import Dispatch` in Support.swift Fixes an occasional Xcode warning display glitch. * Fix Protector.read() to no longer require an `escaping` block * Adds back `Protector.write(_:completion:)` Although, like the new write(_:) method, this is now synchronous. * Wrap all properties of Procedure in a Protector to ensure thread-safety `errors`, `observers`, `directDependencies`, `conditions` (and associated methods) are now thread-safe * Fix comment formatting * Removes @testable import (#600) Exposes NSLock and NSRecursiveLock extensions * Add RepeatProcedure cancellation stress test (#602) * Adds more GroupProcedure test coverage (#603) * Additional / improved GroupProcedure test cases * Remove unused private setter * Refactors of Result Injection APIs (#601) * [OPR-601]: Renamed PendingResult to PendingProfileResult * [OPR-601]: Adds protocols for Input & Output * [OPR-601]: Refactors for InputProcedure & OutputProcedure * [OPR-601]: Refactors ReduceProcedure as a TransformProcedure subclass * [OPR-601]: Refactoring for InputProcedure & OutputProcedure * [OPR-601]: Refactoring Condition to use Result<Bool> * [OPR-601]: Refactors ProcedureKitNetwork result injection * [OPR-601]: Refactors Location for result injection * [OPR-601]: Removes ResultInjection.swift * [OPR-601]: Removes left over properties * [OPR-601]: Tidies up ResultProcedure & TransformProcedure * [OPR-601]: Adds finish(withResult:) API * [OPR-601]: Refactors to use finish(withResult:) * [OPR-601]: Renames HTTPRequirement & HTTPResult * Renames Result to ProcedureResult (#605) * [OPR-605]: Renames Result to ProcedureResult Just to help with any interop issues with antitypical/Result * [OPR-605]: Renames Result to ProcedureResult * Adds AsyncBlockProcedure (#606) * [OPR-606]: Adds AsyncBlockProcedure As a specialization of AsyncResultProcedure * [OPR-606]: Moves async block tests into same file * [OPR-606]: Adds AsyncTransformProcedure * Adds @escaping marker to the FinishingBlock (#607) * Fixes NetworkActivityController internal timer (#608) * NetworkActivityController's delayed hide should occur on the queue Fixes data race. * Remove outdated test * NetworkDataProcedure, NetworkDownloadProcedure, NetworkUploadProcedure thread-safety (#609) * Adds NetworkProcedure (#561) * [OPR-561]: Refactoring ResilientNetworkProcedure - Supports request timeout - Adds HTTPStatusCode where we only even consider retrying client or server errors. - Adds some initial tests * [OPR-561]: Refactors NetworkResilience * [OPR-561]: Refactor to unify reachable & resilience network procedures * [OPR-561]: Adds resilience error handling support This is so that even if the network request “succeeds” but results in say, a server error, we will still trigger retries. * [OPR-561]: Fixes typos * Add missing imports to make Xcode happier (#611) * Add explicit imports to the top of ProcedureKit files This makes Xcode happier. * Add missing imports to the top of ProcedureKitCloud files This makes Xcode happier. * Add missing imports to the top of ProcedureKitMobile files This makes Xcode happier. * Add missing imports to the top of ProcedureKitLocation files This makes Xcode happier. * Fixes BackgroundObserver data race (#614) * Makes NetworkObserver cross-platform (#613) * NetworkObserver and NetworkActivityController cross-platform work On all platforms, the following initializers are available: `NetworkObserver.init(controller: NetworkActivityController)` `NetworkActivityController.init(timerInterval: TimeInterval = 1.0, indicator: NetworkActivityIndicatorProtocol)` To implement your own network activity indicator display, conform to `NetworkActivityIndicatorProtocol`. NetworkActivityController ensures that all accesses of the indicator’s `networkActivityIndicatorVisible` property are serialized on the main queue. On iOS (but *not* in application extensions), the following convenience initializers are available that utilize `UIApplication.shared` to display/hide the network activity indicator in the status bar: `NetworkObserver.init()` `NetworkActivityController.init(timerInterval: TimeInterval = 1.0)` `NetworkActivityController.shared` * [OPR-612]: Moves NetworkObserver into Network framework * [OPR-612]: Moves NetworkObserver into ProcedureKit Keeps iOS non-extension related elements in ProcedureKitMobile * Add documentation * Fixes BackgroundObserver on iOS 8.x (#615) To support iOS < 9.0 and macOS < 10.11, NotificationCenter observers **must** be properly removed, or a crash may result. * Fixes DelayProcedure thread-safety (#616) * Fixes to Location related procedures (#619) * Capability.Location should set its registrar's delegate to nil on deinit. CLLocationManager’s delegate is `unowned(unsafe)`, and we must ensure it is set to nil before the object goes away. The only strong reference to the delegate that Capability.Location sets is stored within Capability.Location. * LocationCapabilityTests tweaks Explicitly set the test CLLocationManager’s `delegate` back to nil. Explicitly wait on `capability.requestAuthorization` to fulfill an expectation. * ReverseGeocodeProcedureTests tweaks * Fix an occasional crash running the Location tests It seems there may be an edge case in CoreLocation triggered when creating (and releasing) lots of CLLocationManager instances (as previously happened when each test, using its own TestableLocationServicesRegistrar, created a “fake” CLLocationManager). Change `TestableLocationServicesRegistrar`’s “fake” CLLocationManager (which is only used to populate a parameter in the delegate callbacks) to a static class variable. * Compiles out SystemConfiguration related stuff from watchOS (#621) * [4.0.0.beta.5]: Beta 5
danthorpe
added a commit
that referenced
this pull request
Dec 16, 2016
* Will Cancel Observer (#293) * [OPR-293]: Refactors Start & Cancellation observers * [OPR-293]: Go back to original group cancellation policy * [OPR-293]: Adds errors to will cancel observer * [OPR-293]: Avoids overriding cancel Instead adds a will cancel observer. * [OPR-293]: Corrects mistake where the queue was not suspended !! * [OPR-293]: Makes cancel a final method This prevents Operation subclasses from overriding cancel. Instead, they should add an observer as appropriate. WillCancelObserver <- block is executed directly before the operation will change its cancellation state. DidCancelObserver <- block is executed directly after the operation did change its cancellation state. Typically, subclasses will want to observe WillCancel to update their own internal state. But consumers will want to observe DidCancel to respond to operations being cancelled. * [OPR-293]: Adds to new operations to property Also makes the queue private. * [OPR-293]: Cancels all operations in the queue. This will ensure that the finishing operation is also cancelled. * [OPR-293]: Adds will/did cancel API * [OPR-293]: Fixes some issues with GroupOperation One of the issues with adding the operations to the queue in the initializer, is that observers will not get notified. So, we have to add the initial operations in `execute`. But, if we append to operations in addOperations, that means, we need to filter out any instances which have already been added. For example, a subclass may well implement execute to first addOperation(myOperation); super.execute() which would cause a crash if we tried adding myOperation twice. * [OPR-293]: Renames will/didFinish This is to be consistent with operationWill/operationDidCancel * Conditions as Operations (#286) * [OPR-278]: Adds protocols for OperationType * [OPR-278]: Creates ConditionOperation With internal types for wrapping OperationCondition, and evaluating groups. * [OPR-278]: Initial work removing ready override. * [OPR-278]: Enables previously failing test * [OPR-278]: Adds missing files to Extension project * [OPR-278]: Enables previously failing test in iOS scheme too * [OPR-278]: Increases the batch size. Also removes the logging. * [OPR-278]: Fixes scheduling of dependencies. * [OPR-278]: Further fixes to dependency scheduling. * [OPR-278]: Removes unnecessary protocols * [OPR-278]: Removes dependency between evaluator and conditons This can introduce a deadlock with mutual exclusivity. * [OPR-278]: Fixes incorrect test with profiler. * [OPR-278]: Enables all tests on OS X * [OPR-278]: Enables all tests on iOS * [OPR-278]: Prevents a retain cycle in ConditionOperation * [OPR-278]: Adds failing test to clarify mutual exclusivity * [OPR-278]: Sets mutual exclusion around operation This was a mistake - it was getting set on the condition. * [OPR-278]: Fixes mutual exclusivity tests * [OPR-278]: Sorts out mutual conditions with dependencies Also, operations which have dependencies, and mutually exclusive conditions which have dependencies. * [OPR-278]: Clean up the code a bit * [OPR-278]: Includes indirect dependencies * [OPR-278]: Starts adding Stress Tests This is a new test bundle which gets tested as part of the OS X test suite. * [OPR-278]: Renames ConditionOperation to Condition It *is* an operation, but I want it to be treated like a Condition with it's own evaluate API * [OPR-278]: Sets up tests * [OPR-278]: Renames to mutuallyExclusive * [OPR-278]: Fixes target reference for Condition.swift * [OPR-278]: Adds ComposedCondition This is useful (and uses automatic result injection) for easily getting the result of a previous condition. * [OPR-278]: Refactors BlockCondition * [OPR-278]: Refactors NegatedCondition * [OPR-278]: Initial work on updating framework conditions - [x] BlockCondition - [x] TrueCondition - [x] FalseCondition - [x] ComposedCondition - [x] SilentCondition - [x] NegatedCondition - [x] MutuallyExclusive - [x] NoFailedDependenciesCondition * [OPR-278]: Corrects a mistake with removeDependencies We we actually just adding?! * [OPR-278]: Mixes the composed direct dependencies * [OPR-278]: Updates UserNotificationCondition to subclass Condition * [OPR-278]: Fixes some tests for iOS * [OPR-278]: Refactors AuthorizedFor * [OPR-278]: Refactors UserConfirmationCondition * [OPR-278]: Refactors ReachabilityCondition * [OPR-278]: Refactors AddressBookCondition * [OPR-278]: Refactors ContactsCondition * [OPR-278]: Refactors RemoteNotificationCondition * [OPR-278]: Adds @available annotation. Still not really sure how to accuractly mark API as deprecated inside a framework. * [OPR-278]: Adds some tests for conditions * [OPR-278]: Refactors condition error type * [OPR-278]: Refactors True False Condition * [OPR-278]: Cleans up Condition tests * [OPR-278]: Fixes tests * Fixes an incorrect Fix-It hint. (#302) Fixes #299. * Fixes notice severity logs (#303) This was done during development and accidentally committed & pushed. Fixes #300 * Fixes bug: CLLocationManager prematurely responds with 'NotDetermined' auth status when asking for permission (#305) * CLLocationAuthorizationStatus bug (#306) * Fixes bug: CLLocationManager prematurely responds with 'NotDetermined' auth status when asking for permission (#305) * [OPR-306]: Adds test coverage for location capability * Improved support for CloudKit Errors (#304) * [OPR-290]: Adds Error associated type on CKOperationType At the moment, this is just fulfilled by NSError, however it will allow us to offer specialized error responses depending on the operation. * [OPR-290]: Updates test cloud kit operation. * [OPR-290]: Adds missing file to Extension project * [OPR-290]: Moves CloudKit sources into a folder * [OPR-290]: Adds errors for Modify Zones & Records * [OPR-290]: Adds custom error types for all CloudKit Operations * [OPR-290]: Fixes error handling Now every CKOperation has it's own bespoke error type. * [OPR-290]: Tidies up AssociatedErrorType * [OPR-290]: Fixes issues with AssociatedErrorType * [OPR-290]: Adds error recovery to BatchedCloudKitOperation * [OPR-290]: Exposes properties on OPRCKOperation These are needed to configure operations inside error handlers. * Removes unnecessary let statement (#310) * Supports entersReaderIfAvailable configuration in WebpageOperation. (#312) It is possible now to show an SFSafariViewController with entersReaderIfAvailable set to false. * Refactors WebpageOperation to subclass ComposedOperation (#315) * Extended WebpageOperation with the ability to configure entersReaderIfAvailable at initialization. It is possible now to show an SFSafariViewController with entersReaderIfAvailable set to false. * Fixed a bug in WebpageOperation that that resulted in a retain cycle. * - Refactored WebpageOperation as ComposedOperation to fix a retain cycle. - Added Documentation. * Fixed some typos in WebpageOperationTests. * Implemented OpenInSafariOperation (#317) * Implemented OpenInSafariOperation * Made the displayControllerFrom non optional. * Refactored OpenInSafariOperation. * Fixes a bug removing dependencies on Condition (#309) The issue is that ComposedCondition must remove the dependency on its composed condition too. * Improves cancellation checks in main() (#319) * [OPR-287]: Invokes observers in main main() is called from start, and we already check that the operation is not cancelled. Therefore the check at the start of main is redundant. However, we don't check after the observers have been executed that the operation is cancelled. * [OPR-287]: SwiftLint fixes. * Exposes LogSeverity enum to Objective-C (#324) * Remove Reachability from CloudKitOperation (#327) * Ignore DS_Store * Rip out reachability from CloudKitOperation * [OPR-327]: Adds trailing closure syntax * [OPR-327]: Adds TimeoutObserver * [OPR-327]: Adds tests for timeout observer * Override NSOperationQueue's mainQueue() (#330) * Override NSOperationQueue's mainQueue() to return the main queue as an OperationQueue * set maxConcurrentOperationCount to 1 * Adds missing functionality of UIAlertController to AlertOperation (#334) * Added missing functionality of UIAlertController to AlertOperation. * Annotated new functionality as public. * Added test cases for new functionality. * Made alert property of AlertOperation private. * SwiftLint corrections. * Added a test for preferredAction and fixed a but related to it. * Made UserIntent enum objc accessbile (#341) * Fixed network observer flickering (#338) Added tests for multiple operations having network observer * Supports error recovery in GroupOperation (#326) * [OPR-326]: Adds Errors subtype in Operation * [OPR-326]: Refactors GroupOperation willFinish API * Revert "[OPR-326]: Adds Errors subtype in Operation" This reverts commit 759f2ef3643cafbbda3544185234b8adeec474ef. * [OPR-326]: WIP on group operation errors * [OPR-326]: Fixes issues with retry operation tests This is still not quite right. * [OPR-326]: Allows RetryOperation to fully recover from errors * [OPR-326]: Fixes issue with tests * [OPR-326]: Tweaks ProfilerTest case * [OPR-326]: Refactors ComposedOperation to just subclass GroupOperation * [OPR-326]: Changes behaviour when a group produces an operation * [OPR-326]: Logs when a GroupOperation successfully recovers from errors * [OPR-326]: Logs when the next operation will be added * [OPR-326]: Adds an immediate WaitStrategy * [OPR-326]: Adds the operation to the log when attempting recovery * [OPR-326]: Removes unneeded handling of child errors * [OPR-326]: Allows the WaitStrategy to be defined at init * [OPR-326]: Changes to support ComposedOperation * [OPR-326]: Speeds up CloudKit tests with .Immediate wait strategy * [OPR-326]: WIP on GroupOperation errors * [OPR-326]: Fixes a bug where operation would not retry In the case where there is a default handler, but no custom one set for the same error. * [OPR-326]: Renames internal methods to be more Swifty * [OPR-326]: Fixes errors - whoops. * Always create CLLocationManager on the main queue (#321) * [OPR-321]: Creates CLLocationManager on the main thread Also makes it thread safe. * [OPR-321]: Refactors capability to use guard & early exit. * [OPR-321]: Creates CLLocationManager lazily on the main thread Refactors UserLocationOperation to not use generic at the same time * [OPR-321]: Fixes deadlock in creating CLLocationManager * [OPR-321]: Refactors location operations for early exit * [OPR-321]: Removes use of NSThread to check for main queue * [OPR-321]: Fixes a mistake with the merge * RepeatedOperation allows for configuration block to be reset by the payload (#348) * [OPR-332]: Adds support for RetryOperation to provide a configuration block * [OPR-332]: Removes commented out code * [OPR-332]: Adds test to check that configure block is replaced * Turns on Whole Module Optimization (#350) Fixes #349 * Exposes the UIAlert for customization. (#351) This also fixes a bug where it wasn't possible to set a barButtonItem on an ActionSheet while presenting as a popover. * Fixes OperationQueue.delegate crash (SR-192) (#353) * Add failing test test__SR_192_OperationQueue_delegate_weak_var_thread_safety: Tests race condition (and crash) involving OperationQueue’s weak delegate var. * Fix for OperationQueue.delegate crash (SR-192) The underlying error is in Swift < 3.0, with concurrent reads of weak properties. See: https://bugs.swift.org/browse/SR-192 This change wraps the public delegate property with an NSLock. It also sets it to nil first-thing in deinit to safely get rid of it. * Simplistic support for CKLimitExceeded error handling (#294) * [OPR-294]: Initial work adding built in support for CKLimitExceeded * [OPR-294]: Rewrite with support for nil response * [OPR-294]: Adds support for adding error handlers in bulk * [OPR-294]: Fixes some comments * [OPR-294]: Moves error handling to CloudKitError * [OPR-294]: Adds BatchProcessErrorType This is only needed for CKMarkNotificationsOperation * [OPR-294]: Renames error protocols * [OPR-294]: Adds support for batch processing * [OPR-294]: Adds & Refactors for tests * [OPR-294]: Minor tweaks * [OPR-294]: Further tweaks * [OPR-294]: Fixes error in bisect * [OPR-294]: Adds API to replace the configure block outright * [OPR-294]: Fixes failing tests * [OPR-294]: Refactors stress tests condition * Adds TaskOperation (#355) * [OPR-313]: Adds TaskOperation * [OPR-313]: Adds more test coverage * [OPR-313]: Adds header documentation * Vastly improves thread safety in Operations (#358) * FIX: GroupOperation.operations contains the initial operations twice after beginning to execute. Cause: `GroupOperation.execute()` calls `GroupOperation.addOperations(operations)`, which then re-adds the operations back to the operations array. Solution: Added a private **`_addOperations()`** method to `GroupOperation` with an additional flag to override this behavior - used in `GroupOperation.execute()`. `addOperations()` now calls this private implementation method. * Operation.cancel(), Operation.finish() thread-safety - `Operation.cancel()` now acquires the stateLock. - `Operation.finish()` now acquires the stateLock. - `stateLock` is now NSRecursiveLock(). - var `Operation.cancelled` is thread-safe. - var `Operation.errors` is thread-safe. - Explicitly send KVO notifications on NSOperation keyPaths at the right times, avoiding lots of unnecessary notifications. - Removed “State” KVO notifications. (Previously used to trigger NSOperation isExecuting/isFinished notifications, which are now triggered explicitly.) - Added missing operationWillFinish() call to finish(). - operationDidFinish() now happens after the state has been set to .Finished. - `Operation.cancelWithError(errors)` now asserts if it’s called while the Operation is finishing or finished. * Operation.main() thread-safety, Operation.disableAutomaticFinishing - `Operation.main()` acquires the stateLock when appropriate. - `Operation.main()` manually sends the isExecuting NSOperation KVO notifications when setting executing state. - Added ability to disable Operation’s automatic calling of finish(), with `init(disableAutomaticFinishing: Bool)`. (Defaults to existing behavior - i.e. false.) * GroupOperation improvements (finish and thread-safety) - GroupOperation should only finish() after its children have finished. - `GroupOperation._addOperations()` acquires the stateLock. - `GroupOperation._addOperations()` cancels new child operations if the GroupOperation is cancelled. * RepeatedOperation.addNextOperation() must check cancelled - RepeatedOperation.addNextOperation() now checks cancelled status. * Added new cancellation-related tests * Added new GroupOperation tests * Added Operation KVO notification tests (for NSOperation keyPaths) * Fixed spurious commit * Handle more possible cases in Operation.main() - Check that the Operation is not already executing. - Check that the Operation has not been finished by a WillExecute observer (either directly or as a side-effect of something else). Added a test case that demonstrates this possibility. * Add missing super.init() calls * More GroupOperation cancelling fixes - Changed the internal WillCancelObserver to a DidCancelObserver to ensure that the cancelled state has been set prior to cancelling child operations. (This ensures that side-effects of propagating cancellation to child operations - like RepeatedOperation attempting to add the next operation - can safely check the cancelled status.) * GroupOperation should not call queue.cancelAllOperations() Calling queue.cancelAllOperations() also cancels the finishingOperation, which skips properly waiting until all other child operations are finished. Fixed test. * Added willProduceOperation method to OperationQueueDelegate, fix GroupOperation handling of child-produced operations Informational method only. This enables GroupOperation to add child-produced operations to its internal operations array, and thus cancel them when the GroupOperation is cancelled. Added tests. * GroupOperation should ignore queue delegate calls from other queues Added missing guard at the top of the queue delegate methods in GroupOperation. Added test to illustrate simple failure case this change covers. * Refactor lock usage in Operation.finish() and .cancel() - Refactor lock usage to hold the stateLock only when necessary or manipulating internal state, and *not* when sending KVO notifications or notifying observers. - Improvements and fixes to KVO Notification Tests. * Further refactor lock usage in Operation (.execute()) - Refactor lock usage in `Operation.execute()` to hold the stateLock only when necessary or manipulating internal state, and *not* when sending KVO notifications or notifying observers. * Add a number of new StressTests that previously failed/crashed New tests have support for a `batches` parameter. * Initial fix for Logging-related crashes (thread-safety issues) - `Operation._log` must not be a lazy var. From the Swift book: > If a property marked with the lazy modifier is accessed by multiple threads simultaneously and the property has not yet been initialized, there is no guarantee that the property will be initialized only once. For more: https://bugs.swift.org/browse/SR-1042 - `Operation.log` must be thread-safe. Initial fix involves capturing a copy of the logging context (settings + operationName) at the time of access of `Operation.log`, returning that captured context as a LoggerType, and surrounding access of .log with a Read/Write lock. - LogManager properties must be thread-safe. * Refactor lock usage in GroupOperation - var `GroupOperation.operations` is now thread-safe. - GroupOperation now utilizes a private CanFinishOperation to safely transition to executing the finishingOperation. (See code & comments.) - GroupOperation now has its own lock that is used sparingly to protect finishing state. - `GroupOperation._addOperation()` now utilizes the groupFinishLock. * Minor tweaks - `Operation.stateLock` should remain private. * SwiftLint clean-up * Refactor lock usage in GroupOperation - Refactor lock usage to hold the groupFinishLock only when necessary or manipulating internal state, and *not* when sending KVO notifications, notifying observers, or changing additionalOperations state (which might send KVO notifications or notify observers). * Clean-up - Remove asserts from `Operation.cancelWithErrors()`. Operation cancellation methods should be safe to call at any time without asserting. - Other minor tweaks. * Clean-up - Moved NSOperationKeyPaths to extension NSOperation.KeyPath enum. * Clean-up * Clean-up - Remove unneeded `self.` * Clean-up * Clarify docs & re-formatting * Add new inits to Queue (NSQualityOfService and qos_class_t) Per code review. * Clean-up of GroupOperation * Make Operation.cancel() final (#359) Per discussion in: https://github.com/danthorpe/Operations/pull/293 https://github.com/danthorpe/Operations/pull/358#discussion_r70167086 * Supports composing simple types for Result injection (#362) * [OPR-362]: Linting whitespace changes * [OPR-362]: Adds support for composing “executors” inside a final Operation type This is a convenience class to aid adoption of _Operations_ without requiring types to subclass Operation. Instead, classes only need to conform to Executor, and then can use the Execute class, which support cancellation, and result injection. * Supports async executors (#363) * Fixes a finished log message (#365) The "Operation Did finish" log was using the opposite logic for error logging * Group's internal queue is non-public; exposes appropriate properties (#361) * Make GroupOperation's internal queue non-public, and expose appropriate properties on GroupOperation - Make GroupOperation.queue ~private~internal. (So it can be tested.) - Expose appropriate run-time editable properties of the GroupOperation’s queue as properties on GroupOperation. Specifically: - public var maxConcurrentOperationCount: Int - public var suspended: Bool - public var qualityOfService: NSQualityOfService - Add tests. * [OPR-361]: Support underlying queue in Group * GatedOperation cancels composed operation when gate is closed (#377) * [OPR-377]: Adds early exit with guard * [OPR-377]: Refactors GatedOperation execute * [OPR-377]: Fixes typo * Result Injection protocol improvements (#378) * [OPR-378]: Updates result injection APIs * [OPR-378]: Adds unit tests * [OPR-378]: Removes unnecessary weak self capture * Fixes dependency gets added twice if it's direct & indirect (#379) * [OPR-379]: Adds a failing unit test * [OPR-379]: Makes indirect dependencies unique set * Removes TaskOperation from non-macOS platforms (#382) * Removes AlertPresentation mutual exclusion (#383) * Adds IgnoredCondition (#385) * Filters out indirect dependencies which have already been added (#386) * Fixes issues with ignored condition (#390) This means that conditions which are ignored mean that the attached operation does not execute, but also does not finish with an error. It’s a nicer use case than GatedOperation. This works by checking the OperationResult for .Ignored and then only cancel() instead of cancelWithError(). Note that if the operation also has .Failed(errors) condition result, in addition to .Ignored then the operation will still not run but this time with errors (as expected). Note that if the operation also has .Satisfied condition result, in addition to .Ignored then the operation will not run, but without errors. * NoFailedDependenciesCondition supports ignoring cancelled operations (#397) Fixes #396. * [OPR-396]: NoFailedDependenciesCondition support ignoring cancels * [OPR-396]: Refactors initializer * [OPR-396]: Renames the condition * Ability to add configuration to the next (retried) CloudKitOperation (#395) * Adds CloudKitOperation.setPrepareForRetryHandler() * Adds BatchedCloudKitOperation.setPrepareForNextOperationHandler() * Clean-up * Updated new APIs, added documentation -Simpler, cleaner, better APIs. -Added documentation and examples for the new APIs. * Add documentation for BatchedCloudKitOperation. * Updates project header (#399) * [OPR-399]: Updates the header * [OPR-399]: Updates the README to point to the new URL for header * Updates guidelines (#400) * [OPR-400]: Updates copyright holders to “ProcedureKit” * [OPR-400]: Adds a code of conduct * [OPR-400]: Fixes a markdown formatting issue * [OPR-400]: Adds CONTRIBUTING guidelines * [OPR-400]: Moves CONTRIBUTING to .github directory * [OPR-400]: Removes an empty section * [OPR-400]: Adds instruction on adding verbose logs. * [OPR-400]: Updates CONTRIBUTING guideline * [OPR-400]: Updates README too * [OPR-400]: Fixes some typos * Creates ProcedureKit project (#401) * [OPR-401]: Sets up ProcedureKit project * [OPR-401]: Adds ProcedureKitMobile This will cover iOS & watchOS * [OPR-401]: Adds ProcedureKitTV * [OPR-401]: Fixes Runtime Search Paths * [OPR-401]: Adds StressTests * [OPR-401]: Adds ProcedureKitMac * [OPR-401]: Enables code coverage on all testable schemes * [OPR-401]: Adds ProcedureKitCloud * [OPR-401]: Changes to module imports * [OPR-401]: Changes Cloud to latest deployment versions * ProcedureKit CI - Stage 1 (#403) * [OPR-403]: Changes Stress Tests to only run as part of the ProcedureKitMac scheme * [OPR-403]: Changes Cloud minimum target versions * [OPR-403]: Adds tests to CI - ProcedureKit macOS * [OPR-403]: Fixes Operations mac tests * [OPR-403]: Fixes Operations tests 2 * [OPR-403]: Fixes Swift version to 2.2 * [OPR-403]: Moves common scripts around * [OPR-403]: Updates scripts * [OPR-403]: Changes to the Fastlane name for mac * [OPR-403]: Updates build dependencies * [OPR-403]: Sets the correct destination platform * [OPR-403]: Updates scan invocation * [OPR-403]: Updates Fastfile * [OPR-403]: Trying to use which to find bundle * [OPR-403]: Using quotes * [OPR-403]: Adds setup first * [OPR-403]: Putting the whole setup into quotes * [OPR-403]: Attempting to add multiple lines to the command * [OPR-403]: Puts it all on one line * [OPR-403]: Adds more ProcedureKit steps * [OPR-403]: Fixes error in Stress Tests build settings * [OPR-403]: Pipline Uploads * [OPR-403]: Fixes pipelines * [OPR-403]: Uses pipeline upload correctly * [OPR-403]: Fixes error in mobile tests * [OPR-403]: Adds watchOS * [OPR-403]: Removes automatic code signing * [OPR-403]: Comments out watchOS builds * [OPR-403]: Adds TV * [OPR-403]: Removes ad-hoc code signing * [OPR-403]: Fixes Operations iOS * [OPR-403]: Sets iPhone Developer automatic code signing * [OPR-403]: Updates buildkite agent tags for iOS Simulator * [OPR-403]: Sets the development team in xcargs * [OPR-403]: Enables automatic code signing without a team set * [OPR-403]: Fixes issues with code signing settings for TV * [OPR-403]: Removes the development team * [OPR-403]: Puts everything into a single pipeline * [OPR-403]: Cleans up the pipeline * [OPR-403]: Sets personal team for mobile unit tests * [OPR-403]: Updates the Fastlane lane names * [OPR-403]: Adds a copy frameworks build phase * [OPR-403]: Removes copy files phase * [OPR-403]: Comments out problematic build jobs * [OPR-403]: Removes Operations CI jobs * ProcedureKit CI - Stage 2 (#404) * Update CI dependencies (#409) * [OPR-409]: Updates dependencies and enables pipeline * [OPR-409]: Fixes YML * [OPR-409]: Fully specifies the destination Starting to really not like Fastlane * [OPR-409]: Switches to iOS 10 simulators. * [OR-409]: Sets the developer directory * [OPR-409]: Removes tvOS for Mobile framework * [OPR-409]: Reorders the jobs * Add base types to ProcedureKit (#405) * [OPR-405]: Creates Procedure * [OPR-405]: Sets the Swift version * [OPR-405]: Cleans project * [OPR-405]: Changes to destination * [OPR-405]: Stops using Fastlane for testing macOS * [OPR-405]: Adds initial files for ProcedureQueue * [OPR-405]: Defines ProcedureObserver * [OPR-405]: Adds the default implementation of ProcedureObserver * [OPR-405]: Adds the rest of the observer protocols * [OPR-405]: Adds @available annotations * [OPR-405]: Adds block based observers * [OPR-405]: Adds Protector / DispatchQueue extension * [OPR-405]: Further updates to observers API * [OPR-405]: Adds extension to Operation This is for addCompletionBlock - but will be used for more stuff when we get into dependencies * [OPR-405]: Fixes lint issues * [OPR-405]: Adds Procedure protocol with AbstractProcedure * [OPR-405]: Starts interfaces in AbstractProcedure for execute & finish * [OPR-405]: Adds state transition * [OPR-405]: Refactors Procedure to be protocol based. * [OPR-405]: Adds most of the cancellaton functionality * [OPR-405]: Adds main implementation With a few TODOs * [OPR-405]: Fixes available renames * [OPR-405]: Changes AbstractProcedure back to Procedure * [OPR-405]: Adds Testing framework With TestProcedure class * [OPR-405]: Adds basic API to ProcedureTestCase * [OPR-405]: Updates dependencies * [OPR-405]: Commenting out non mac unit tests Run CI on iOS Simulators is basically impossible on beta version of Xcode. * [OPR-405]: Adds finishing and cancellation tests * [OPR-405]: Adds some finishing tests * Adds Logging (#428) * [OPR-428]: Adds LogSeverity * [OPR-428]: Adds logger * [OPR-428]: Updates logging stuff * [OPR-428]: Adds logging tests * Group (#430) * [OPR-430]: Adds Group * [OPR-430]: Adds initializers to Group * [OPR-430]: Adds add child API to Group * [OPR-430]: Corrects spelling * [OPR-430]: Adds finishing APIs to Group * [OPR-430]: Adds extension of unavailable APIs * [OPR-430]: Adds GroupObserverProtocol * [OPR-430]: Adds error handling and recovery to Group * [OPR-430]: Improves group observers API * [OPR-430]: Adds first group test * [OPR-430]: Adds some basic tests for Group * [OPR-430]: Adds more unit test for Group * [OPR-430]: More tests for group * Adds User Intent (#439) * [OPR-439]: Adds UserIntent to Procedure * [OPR-439]: Adds userIntent to Group * Stress Tests Phase 1 (#442) * [OPR-442]: Adds StressTestCase and completion block stress tests * [OPR-442]: Uses StressLevel directly. * [OPR-442]: Refactors the test case names * [OPR-442]: Refactors to remove StressTestCase Instead the stress function can be added to the base ProcedureKitTestCase * [OPR-442]: Adds group cancel stress test * [OPR-422]: Refactors group stress tests These are currently failing * [OPR-422]: Refactors schemes, as stress tests are run as part of Mac tests * [OPR-442]: Updates Stress Tests batches Uses intermediate BatchProtocol, and exposes a measure API. * [OPR-422]: Changes the active developer directory * [OPR-422]: Adds group child finishing order stress test * [OPR-422]: Fixes incorrect pipeline step * [OPR-422]: Adds more stress tests for Procedure * [OPR-422]: Fixes TestError mistake * [OPR-422]: Changes to use didCancelBlockObserver Instead of didFinishBlockObserver - there might be a subtle bug here. * [OPR-422]: Disables some checks - have identified that there is definitely an error in finishing logic * [OPR-422]: Moves stress tests to their own scheme * [OPR-422]: Adds stress fastlane * [OPR-422]: Trying to see how to trigger stress tests * [OPR-422]: Removing - * [OPR-422]: Changes the trigger to ProcedureKit * [OPR-422]: Add the pipeline update step back * [OPR-422]: Fixes yml * [OPR-422]: More changes to pipeline template * [OPR-422]: Fixes the slug This is case sensitive! * [OPR-422]: Triggers a different pipeline stress tests * [OPR-422]: Adds commit message to stress test build * [OPR-422]: Modifies measure to be a little quicker * [OPR-422]: Updates baselines with Mac Pro * [OPR-422]: Fixes mistake with finishing from cancel * Fix issue with newlines in pipeline upload (#445) * [OPR-445]: Removes message from upload script * [OPR-422]: Puts the commit back * Initial work on Result Injection (#446) * Adds Dependencies & Conditions (#429) * [OPR-429]: Adds Condition protocol and class * [OPR-429]: Adds conditions to procedure and queue * [OPR-429]: Adds tests for Conditions Also adds XCTAssertProcedure functions to make verifying Procedure behaviour more consistent. * [OPR-429]: Adds remaining unit tests for conditions Still got Ignored Condition to add * [OPR-429]: Fixes some documentation * [OPR-429]: Performs the stress tests in the same build * [OPR-422]: Adds stress tests for conditions * [OPR-429]: Adds IgnoredCondition * ProcedureKitError (#437) * [OPR-437]: Regorganized the Core group * [OPR-437]: Refactors Errors into ProcedureKitError * Completes Result Injection API test coverage (#447) * [OPR-447]: Sorts out ResultInjection * [OPR-447]: Completes result injection tests * Fixes Xcode 8 GM issues (#463) * BlockProcedure (#450) * [OPR-450]: Adds BlockProcedure * [OPR-450]: Adds unit tests for map and block procedures * [OPR-450]: Adds some stress tests for block procedure * [OPR-450]: Updates stress tests * [OPR-450]: Fixes Xcode 8 GM escaping issue * [OPR-450]: Papers over some possible issues with finishing. In many cases the `should finish after cancelling` logic is returning false. * [OPR-450]: Removes some excessive logging * [OPR-450]: Adjusts variation to 15% * Mutual exclusive conditions (#448) * [OPR-448]: Adds MutualExclusion * [OPR-448]: Adds support for adding dependencies for mutual exclusion * [OPR-448]: WIP on mutual exclusivity * [OPR-448]: Finishes off test cases for mutual exclusivity * [OPR-448]: Refactors add condition API to attach condition I want to make the API consistent - but not choose consistency over intent. So, `add(dependency: myDependency)` makes sense - as it signals that the dependency is already managed by some other queue/system. Where as for a Condition, we specifically _attach_ it to Procedure instance, and it does not (ideally should not) be managed outside the Procedure. So, I want the concept of “attaching conditions to procedures” to be the language which is used to describe the behaviour. * DelayProcedure (#449) * [OPR-449]: Adds delay procedure * [OPR-449]: Adds DelayProcedure tests * Renames Group to GroupProcedure (#468) * Adds ProcedureKit.podspec (#467) * Adds NegatedCondition (#471) * Adds SilentCondition (#472) * Procedure finishing fixes (#474) * Resolve finishing issues related to FinishingFrom. * Add StressTest that covers concurrent calls to finish() * Revert ProcedureKitTestCase expectation fulfillment back to the main queue. * Adds BlockCondition (#473) * Adds NoFailedDependenciesCondition (#470) * Adds TimeoutObserver (#475) * [OPR-475]: Adds TimeoutObserver * [OPR-475]: Fixes issues with TestProcedure It was not correctly delaying. * Procedure name and identity (#478) * [OPR-478]: Adds name and Identity * [OPR-478]: Fixes some failing tests * [OPR-478]: Fixes another failing name test * Adds BlockObserver (#480) * [OPR-480]: Adds BlockObserver * [OPR-480]: Tweaks to stress tests * Adds ComposedProcedure & GatedProcedure (#487) * RepeatProcedure (#488) * [OPR-488]: Initial work on RepeatProcedure * [OPR-488]: Adds remaining test coverage * RetryProcedure (#491) * [OPR-491]: Adds RetryProcedure * [OPR-491]: Unifies the generic init pattern for repeat and retry procedures * Adds support for Capabilities (#492) * [OPR-492]: Fixes incorrectly spelt protocol * [OPR-492]: Adds Capability Including CapabilityProtocol, GetAuthorizationStatus, Authorize, AuthorizedFor * Adds BackgroundObserver (#476) * [OPR-476]: Fixes stress tests * [OPR-476]: Adds BackgroundObserver * [OPR-476]: Gets the Mobile test suite working * [OPR-476]: Switches code coverage on * [OPR-476]: Adds missing callback This was causing a failing unit test * [OPR-476]: Removes unnecessary build phase * [OPR-476]: Finishes BackgroundObserver tests * [OPR-476]: Removes verbose logging in test case * Adds FilterProcedure (#496) * [OPR-496]: Adds FilterProcedure * [OPR-496]: Adds filter method for when Result is a sequence * Adds ReduceProcedure (#497) * [OPR-497]: Adds ReduceProcedure * [OPR-497]: Refactors Map, Filter adds FlatMap MapProcedure is really a TransformProcedure. MapProcedure and FilterProcedure are now simple subclasses of ReduceProcedure, along with FlatMapProcedure. * Adds NetworkObserver (#498) * [OPR-498]: Adds NetworkObserver Additionally, this updated ProcedureKitTestCase to automatically add async expectation fulfills around operations which might be produced by a procedure. * [OPR-498]: Refactors ProcedureKitTestCase slightly for Swift 3 conventions. * Adds Location.Capability (#499) * [OPR-499]: Adds ProcedureKitLocation framework * [OPR-499]: Supports sychronous dispatch onto the main queue This is safe to call if already on the main queue. * [OPR-499]: Adds Capability.Location * Adds UserLocationProcedure (#500) * [OPR-500]: Adds UserLocationProcedure * [OPR-500]: Removes unneeded error struct * [OPR-500]: Fixes issue with tvOS * Corrects minimum deployment targets (#503) Fixes #501 * [OPR-501]: Fixes issues with deployment versions * [OPR-501]: Setting tvOS to 9.2 * Adds ReverseGeocodeProcedure (#502) * [OPR-502]: Adds ReverseGeocodeProcedure * [OPR-502]: Adds ProcedureKitMobile as a build dependency * [OPR-502]: Fixes a mistake where macOS location tests were requiring iOS simulator * [OPR-502]: Uses gym to ensure iOS builds ProcedureKitMobile before testing Location * [OPR-502]: Use scan instead of gym This is a hack. I want to make sure that when we test ProcedureKitLocation on iOS we have build ProcedureKitMobile. * Adds ReverseGeocodeUserLocationProcedure (#504) * [OPR-504]: Adds/renames files * [OPR-504]: Adds ReverseGeocodeUserLocationProcedure * [OPR-504]: Rounds out the unit tests on ReverseGeocodeUserLocationProcedure * Makes procedures open where appropriate (#510) * Refactors BlockProcedure (#511) * Adds AnyProcedure (#516) * [OPR-516]: Removes import foundation This is done by the prefix header * [OPR-516]: Adds AnyProcedure * [OPR-516]: Uses the correct underlying queue throughout AnyProcedure * Fixes regression of failing release build (#518) * Renames AuthorizationStatusProtocol to AuthorizationStatus (#519) * Renames capability reated procedures (#520) * Renames attach(condition: Condition) to add (#521) * Adds Capability.CloudKit (#523) * [OPR-523]: Adds Capability.CloudKit * [OPR-523]: Enables CI builds for CloudKit stuff on iOS and tvOS * Adds ProcedureKitNetwork framework (#524) * [OPR-524]: Adds ProcedureKitNetwork framework * [OPR-524]: Adds Network to CI jobs * [OPR-524]: Renames Stress Tests job * [OPR-524]: Shares the network scheme * [OPR-524]: Imports Foundation instead of Cocoa * [OPR-524]: Forces Stress Tests onto a non-simulator agent * Adds NetworkDataProcedure (#525) * [OPR-525]: Adds NetworkDataProcedure * [OPR-525]: Fixes up some unit tests * [OPR-525]: Adds missing test coverage * Moves TestableNetwork into TestingProcedureKit framework (#526) * Refactors injectDependency API to be an extension on ProcedureProtocol instead. (#527) * Adds transform block result injection API (#528) * [OPR-528]: Refactors result injection Uses an intermediatory injectResult(from: via:) API, which allows the caller to provide a throwing block to transform the result into the requirement. * [OPR-528]: Removes unneeded return * [OPR-528]: Fixes error in ProcedureKitLocation * Adds default empty implementations some queue delegate methods (#531) Only added the will-do-something ones. Fixes #530 * Adds space in the repo for presentations (#533) * [OPR-533]: Adds CocoaHeads Stockholm talk Contact @danthorpe if you want the original Keynote file. * [OPR-533]: Adds Sky-UK iOS Community Talk * [OPR-533]: Adds a presentations README * Disables the log for AnyProcedure (#534) * Fixes bug where GroupProcedure collects errors from children after its been cancelled (#532) * [OPR-532]: Adds failing test * [OPR-532]: Checks cancelled state of the group We can exit this delegate callback early if the group has already been cancelled. * [OPR-532]: Removes default implementation of willFinish It seems that adding default implementations here causes some odd behaviour / intermittent crash where this is overwritten in the QueueDelegate. * [OPR-532]: Fixes a unit test which is now mis-counting errors. * Adds .then { } API (#536) * [OPR-176]: Adds then extension on Operation * [OPR-176]: Implements .then { } API * [OPR-176]: Adds enqueue method to a collection of Operations * [OPR-176]: Fixes header docs * Removes default argument for session in NetworkDataProcedure (#538) * Tweaks the cancel block procedure stress tests (#539) There might be an underlying issue. As normally a batch of 10_000 finishing in ~ 5 seconds. But sometimes fails because it times out, meaning that an expectation is not getting fulfilled. * Moves ProcedureKit imports to umbrella headers (#540) * [OPR-540]: Putting the appropriate imports into umbrella headers * [OPR-540]: Fixing issues with importing ProcedureKit into TestingProcedureKit * Updates ProcedureKit podspec with subspecs (#508) * [OPR-508]: Lints podspec without an warnings or errors. * [OPR-508]: Fixes errors running tests * Adds ResilientNetworkProcedure (#537) * [OPR-537] Adds ResilientNetworkProcedure * [OPR-537]: Updates retry request with error code * [OPR-537]: Adds edge case for ResilientNetworkProcedure In some situations, the HTTP status code might well require (depending on the behaviour) a retry. * [OPR-537]: Fixes simple unit tests * Refactor ResultInjection to use PendingValue enum (#541) * [OPR-541]: Refactors ResultInjectionProtocol to use PendingValue enum * [OPR-541]: Renames ResultInjectionProtocol to ResultInjection * Fixes BlockProcedure stress tests (#544) * [OPR-544]: Fix test__cancel_block_procedure() failures It was possible for the testing BlockProcedure to finish prior to the `block.cancel()` call, which would result in some of the BlockProcedures never cancelling (as they had finished first), and a failing test. Fixed by using a semaphore inside the BlockProcedure’s block. Additionally, the test now waits for all BlockProcedures to cancel *and* finish. * [OPR-544]: Added a new stress test for BlockProcedure cancelling & finishing behavior (allowing for possible races between cancelling and finishing) * Fixes ExclusivityManager synchronization bug (#545) Fixes #543 The ExclusivityManager was using `DispatchQueue.initiated`, which returns a global **concurrent** queue, however its internals are dependent upon **serial** execution of add/remove. Modified to use a serial queue. * Adds ResultProcedure and overloads injectResult(from:) (#546) * Adds HTTPResult<Payload> (#547) * Fix test crashes caused by QueueTestDelegate (#549) QueueTestDelegate was not thread-safe. This could result in crashes running random tests. Fixed by making QueueTestDelegate’s methods thread-safe. * Adds ProcedureKitTestCase wait function that takes an array (#552) * Adds TestingProcedureKit podspec (#553) * Adds Mutual Exclusivity concurrency testing (#550) * Add ConcurrencyTestCase Exposes functionality to test operation concurrency. * Add Mutual Exclusivity concurrency tests * Refactored ConcurrencyTestCase * Refactored ConcurrencyTestCase * Adds didExecuteObserver (#554) * [OPR-554]: Adds code with failing test * [OPR-554]: Calls didExecuteObservers * [OPR-554]: Fixes a typo * [OPR-554]: Adds some documentation to the DidExecuteObserver * Fixes mistake in Fastfile (#557) * [OPR-557]: Fixes error in Fastfile * [OPR-557]: Removes duplicate scan I remember now, as part of location, we used to build Mobile too - because there was a dependency on iOS. But this has since been removed. * Fixes release configuration issues with Xcode 8.1 (#559) Fixes #548 * [OPR-548]: Fixes issue with Xcode 8.1 release configuration * [OPR-548]: Fixes some SwiftLint warnings. * [OPR-548]: Fixes Xcode project warnings in Xcode 8.1 * Adds GroupProcedure concurrency tests (#556) * Add GroupConcurrencyTestCase * Add GroupProcedure.maxConcurrentOperationCount tests * Fixes registrar typo (#562) * Adds NetworkDownloadProcedure. (#565) The implementation for class and test is largely inspired by `NetworkDataProcedure` class. * Adds NetworkUploadProcedure. (#567) * Add NetworkUploadProcedure. The implementation class and test has been largely inspired by `NetworkDataProcedure`. The requirement type is currently a pending value of a tuple. Maybe would it make more sense to create a dedicated struct to add more clarity in the case of dependencies injection ? * Use an `HTTPRequirement` struct for requirement. As discussed, an `HTTPRequirement` struct is used instead of a tuple. * Fixes Condition to support ResultInjection (#566) * [OPR-566]: Replaces Condition result with PendingValue<ConditionResult> * [OPR-566]: Refactors how conditions are evaluated This fixes a existing issue where the ConditionEvaluation enum was basically just like ConditonResult, except that it could hold an array of errors. This has been resolved by using an internal error type `ProcedureKitError.FailedConditions` to collect multiple errors from failed conditons, so that we can reduce a sequence of `ConditionResult`s into a single one. * [OPR-566]: Explicitly adds a Result typealias * [OPR-566]: Fixes error where cancelled conditions would throw a fatal error. * [OPR-566]: Removes verbose log * Adds ProcessProcedure. (#570) * Add ProcessProcedure. The class has been largely inspired by the original `TaskOperation`. Refers to #568. * Apply requested changes. Correctly implement `Equatable` for sub-error enum. Use camel case for the enum. Fix closure self semantics. * Calls TestableReverseGeocoder completionHandler on the main queue (#572) * Improves performance of adding observers * Procedure.add(observer:) performance tweak Append directly to the protected observers array. * Fix swiftlint `variable_name` warning * Makes ProcedureQueue.add(operation: Operation) method open (#578) * Fixes NetworkObserver thread-safety (#576) (#577) * Fix NetworkObserver thread-safety By fixing NetworkActivityController `start()`/`stop()` thread-safety. (And making private methods/variables private.) * NetworkObserver test fixes * Reduce test delay * Additional GroupProcedure tests (#579) * Adds CloudKitProcedure (#542) * [OPR-542]: Adds shell of CloudKit files * [OPR-542]: Adds extensions for CKOperation * [OPR-542]: Adds extensions for CKDatabaseOperation * [OPR-542]: Adds extensions for CKAcceptSharesOperation * [OPR-542]: Adds extensions for CKDiscoverAllContactsOperation * [OPR-542]: Adds extensions for CKDiscoverAllUserIdentifiesOperation * [OPR-542]: Adds extensions for CKDiscoverUserIdentitiesOperation * [OPR-542]: Adds extensions for CKDiscoverUserInfosOperation * [OPR-542]: Adds extensions for CKFetchDatabaseChanges * [OPR-542]: Adds extensions for CKFetchDatabaseChangesOperation * [OPR-542]: Adds extensions for CKFetchRecordChangesOperation * [OPR-542]: Moves the interface into the extension files * [OPR-542]: Fixes dispatchQueue * [OPR-542]: Adds extensions to CKFetchRecordsOperation * [OPR-542]: Adds extensions for CKFetchRecordZoneChangesOperation * [OPR-542]: Removes unnecessary public properties * [OPR-542]: Adds extensions for CKFetchRecordZonesOperation * [OPR-542]: Adds extensions for CKFetchShareMetadataOperation * [OPR-542]: Adds extensions for CKFetchShareParticipantsOperation * [OPR-542]: Adds extensions for CKFetchSubscriptionsOperation * [OPR-542]: Adds extensions for CKMarkNotificationsReadOperation * [OPR-542]: Adds extensions for CKModifyBadgeOperation * [OPR-542]: Adds extensions for CKModifyRecordsOperation * [OPR-542]: Adds extensions for CKModifyRecordZonesOperation * [OPR-542]: Adds extensions for CKModifySubscriptionsOperation * [OPR-542]: Adds extensions for CKQueryOperation * [OPR-542]: Adds missing APIs for error handlers * [OPR-542]: Adds testable CK operation classes * [OPR-542]: Adds tests for CKOperation, CKDatabaseOperation and CKAcceptSharesOperation * [OPR-542]: Removes missing test cases from tvOS * Small typo fix * Adds tests for CKDiscoverAllContactsOperation * Adds tests for CKDiscoverAllUserIdentitiesOperation * Adds tests for CKDiscoverUserIdentitiesOperation * Adds tests for CKDiscoverUserInfosOperation * [OPR-542]: Adds tests for CKFetchAllChanges protocol * [OPR-542]: Adds tests for CKFetchDatabaseChangesOperation * [OPR-542]: Adds tests for CKFetchNotificationChangesOperation * [OPR-542]: Adds tests for CKFetchRecordChangesOperation * [OPR-542]: Adds tests for CKFetchRecordsOperation * [OPR-542]: Added missing `recordZoneFetchCompletionBlock` for CKFetchRecordZoneChangesOperationProtocol extensions * [OPR-542]: Adds tests for CKFetchRecordZoneChangesOperation * [OPR-542]: Adds tests for CKFetchRecordZonesOperation * [OPR-542]: Adds tests for CKFetchShareMetadataOperation * [OPR-542]: Adds tests for CKFetchShareParticipantsOperation * [OPR-542]: Adds tests for CKFetchSubscriptionsOperation * [OPR-542]: Minor typo fix To follow the original API naming, change `setMarkNotificationReadCompletionBlock` to `setMarkNotificationsReadCompletionBlock`. * [OPR-542]: Adds tests for CKMarkNotificationsReadOperation * [OPR-542]: Adds tests for CKModifyBadgeOperation * [OPR-542]: Adds tests for CKModifyRecordsOperation * [OPR-542]: Adds tests for CKModifyRecordZonesOperation * [OPR-542]: Adds tests for CKModifySubscriptionsOperation * [OPR-542]: Adds tests for CKQueryOperation * [OPR-542]: Fixes whitespace in test cases * [OPR-542]: Adds CloudKitProcedure<CKAcceptSharesOperation> tests * [OPR-542]: Fixes tests on tvOS. Again. * [OPR-542]: Adds tests for CKDiscoverAllContactsOperation * [OPR-542]: Adds tests for CKDiscoverAllUserIdentitiesOperation * [OPR-542]: Adds tests for CKDiscoverUserIdentitiesOperation * [OPR-542]: Adds tests for CKDiscoverUserInfosOperations * [OPR-542]: Adds tests for CKFetchDatabaseChangesOperation * [OPR-542]: Unifies testing of common properites * [OPR-542]: Adds tests for CKFetchNotificationChangesOperation * [OPR-542]: Adds tests for CKFetchRecordChangesOperation * [OPR-542]: Adds test for CKFetchRecordsOperation * [OPR-542]: Adds tests for CKFetchRecordZoneChangesOperation * [OPR-542]: Adds test for CKFetchRecordZonesOperation * [OPR-542]: Adds tests for CKFetchShareMetadataOperation * [OPR-542]: Adds tests for CKFetchShareParticipantsOperation * [OPR-542]: Fixes inconsistently named tests * [OPR-542]: Adds tests for CKFetchSubscriptionsOperation * [OPR-542]: Adds tests for CKMarkNotificationsReadOperation * [OPR-542]: Adds tests for CKModifyBadgeOperation * [OPR-542]: Adds tests for CKModifyRecordsOperation * [OPR-542]: Adds tests for CKModifyRecordZonesOperation * [OPR-542]: Adds test for CKModifySubscriptionsOperation * [OPR-542]: Adds test for CKQueryOperation * [OPR-542]: Adds tests which trigger default retry behavior * [OPR-542]: Adds tests for set/get all errors handlers * [OPR-542]: Adds tests for custom error handlers * Adds Profiler (#573) * Implement Profiler as specified in #569. The implmentation is largely inspired by the original `Profiler.swift` file. * Add first set of tests. The test has been largely inspired by the original tests classes. I have a commented test taht fails. After trying to debug for a while, I suspect maybe an issue inside GroupProcedure or the original implementation. * Apply requested changes. Perform changes as requested. * Adds public initialiser to HTTPRequirement (#586) Declaring a constructor for the `HTTPRequirement` allows the construction of the struct without any issue. * Removes GroupProcedureObserver protocol (#583) Instead ProcedureObserver takes over this responsibility. * [OPR-574]: Cleans up white space & style for consistency * [OPR-574]: Uncomments failing test * [OPR-574]: Adds new API to ProcedureObserver protocol * [OPR-574]: Removes temporary print statements * [OPR-574]: Refactors to support willAdd & didAdd observer callbacks. * [OPR-574]: Removes commented out line. * [OPR-574]: Removes group observers. * [OPR-574]: Removes extraneous logging in some tests * [OPR-574]: Makes add(observer:) open for overriding * [OPR-574]: Adds some documentation comments to public interfaces * Supports Arbitrary mutual exclusion category names (#587) Fixes #580. * [OPR-580]: Supports arbitrary mutual exclusion category names * [OPR-580]: Fixes default category for AuthorizedFor * Adds NetworkReachableProcedure (#563) * [OPR-563]: Adds Reachability functionality * [OPR-563]: Adds additional files for testing support * [OPR-563]: Adds tests for Reachability * [OPR-563]: Adds basis of NetworkReachableProcedure * [OPR-563]: Adds simple network reachability procedure tests * [OPR-563]: Fixes issue with Protector write being synchronous. * [OPR-563]: Refactors DeviceReachability slightly * [OPR-563]: Changes Protector behavior back to be non-blocking * [OPR-563]: Fixes Reachability.Device * [OPR-563]: Adds NetworkProcedure and ProcedureKitNetworkError * [OPR-563]: Fixes for network error tests * [OPR-563]: Adds remaining tests for Reachable procedure * [OPR-563]: Removes unnecessary logging * Refactors produce API (#588) * Add failing test * Test tweaks * Changes to Procedure.produce(operation:) handling Fixes failing test case, and simplifies execution flow. Changes `willEnqueue()` to `willEnqueue(on: ProcedureQueue)`. `func produce(operation: Operation)` now throws. * Ported additional test case from Operations 3.x. * swiftlint tweak * Fixed mobile tests. * Adds missing equality cases for ProcedureKitError.Context (#591) Fixes #589 * Supports merging collections of ResultInjection Procedures (#593) * [OPR-593]: Adds gather and reduce APIs * [OPR-593]: Removes the rethrows While the nextPartialResult closure can throw, this error is not re-thrown. Instead, because this block is executed after the receiver’s procedures have all finished, the error means that the `ResultProcedure` will finish with an error. * [OPR-593]: Adds test case for throwing closure * [OPR-593]: Refactors gather() so that it is a specialization of new flatMap API * Improves how stress tests are run in CI (#594) * [OPR-594]: Updates pipeline queues * [OPR-594]: Fixes yaml * [OPR-594]: Disables Thread Sanitizer for Stress Tests * [OPR-594]: Uses Release configuration for stress tests * Fix StressTestCase Batch counters thread-safety (#555) (#596) * Fixes public access levels for CKProcedure (#599) * Fixes some RepeatProcedure thread-safety issues (#597) Fix issues identified by an audit and Thread Sanitizer * Fixes Procedure & Support thread-safety (#598) * Change Protector.write() to be synchronous (and optionally return a value from the block) Thread Sanitizer identified a data race caused by the combination of the prior asynchronous `write()` and deinitialization. * Explicitly `import Dispatch` in Support.swift Fixes an occasional Xcode warning display glitch. * Fix Protector.read() to no longer require an `escaping` block * Adds back `Protector.write(_:completion:)` Although, like the new write(_:) method, this is now synchronous. * Wrap all properties of Procedure in a Protector to ensure thread-safety `errors`, `observers`, `directDependencies`, `conditions` (and associated methods) are now thread-safe * Fix comment formatting * Removes @testable import (#600) Exposes NSLock and NSRecursiveLock extensions * Add RepeatProcedure cancellation stress test (#602) * Adds more GroupProcedure test coverage (#603) * Additional / improved GroupProcedure test cases * Remove unused private setter * Refactors of Result Injection APIs (#601) * [OPR-601]: Renamed PendingResult to PendingProfileResult * [OPR-601]: Adds protocols for Input & Output * [OPR-601]: Refactors for InputProcedure & OutputProcedure * [OPR-601]: Refactors ReduceProcedure as a TransformProcedure subclass * [OPR-601]: Refactoring for InputProcedure & OutputProcedure * [OPR-601]: Refactoring Condition to use Result<Bool> * [OPR-601]: Refactors ProcedureKitNetwork result injection * [OPR-601]: Refactors Location for result injection * [OPR-601]: Removes ResultInjection.swift * [OPR-601]: Removes left over properties * [OPR-601]: Tidies up ResultProcedure & TransformProcedure * [OPR-601]: Adds finish(withResult:) API * [OPR-601]: Refactors to use finish(withResult:) * [OPR-601]: Renames HTTPRequirement & HTTPResult * Renames Result to ProcedureResult (#605) * [OPR-605]: Renames Result to ProcedureResult Just to help with any interop issues with antitypical/Result * [OPR-605]: Renames Result to ProcedureResult * Adds AsyncBlockProcedure (#606) * [OPR-606]: Adds AsyncBlockProcedure As a specialization of AsyncResultProcedure * [OPR-606]: Moves async block tests into same file * [OPR-606]: Adds AsyncTransformProcedure * Adds @escaping marker to the FinishingBlock (#607) * Fixes NetworkActivityController internal timer (#608) * NetworkActivityController's delayed hide should occur on the queue Fixes data race. * Remove outdated test * NetworkDataProcedure, NetworkDownloadProcedure, NetworkUploadProcedure thread-safety (#609) * Adds NetworkProcedure (#561) * [OPR-561]: Refactoring ResilientNetworkProcedure - Supports request timeout - Adds HTTPStatusCode where we only even consider retrying client or server errors. - Adds some initial tests * [OPR-561]: Refactors NetworkResilience * [OPR-561]: Refactor to unify reachable & resilience network procedures * [OPR-561]: Adds resilience error handling support This is so that even if the network request “succeeds” but results in say, a server error, we will still trigger retries. * [OPR-561]: Fixes typos * Add missing imports to make Xcode happier (#611) * Add explicit imports to the top of ProcedureKit files This makes Xcode happier. * Add missing imports to the top of ProcedureKitCloud files This makes Xcode happier. * Add missing imports to the top of ProcedureKitMobile files This makes Xcode happier. * Add missing imports to the top of ProcedureKitLocation files This makes Xcode happier. * Fixes BackgroundObserver data race (#614) * Makes NetworkObserver cross-platform (#613) * NetworkObserver and NetworkActivityController cross-platform work On all platforms, the following initializers are available: `NetworkObserver.init(controller: NetworkActivityController)` `NetworkActivityController.init(timerInterval: TimeInterval = 1.0, indicator: NetworkActivityIndicatorProtocol)` To implement your own network activity indicator display, conform to `NetworkActivityIndicatorProtocol`. NetworkActivityController ensures that all accesses of the indicator’s `networkActivityIndicatorVisible` property are serialized on the main queue. On iOS (but *not* in application extensions), the following convenience initializers are available that utilize `UIApplication.shared` to display/hide the network activity indicator in the status bar: `NetworkObserver.init()` `NetworkActivityController.init(timerInterval: TimeInterval = 1.0)` `NetworkActivityController.shared` * [OPR-612]: Moves NetworkObserver into Network framework * [OPR-612]: Moves NetworkObserver into ProcedureKit Keeps iOS non-extension related elements in ProcedureKitMobile * Add documentation * Fixes BackgroundObserver on iOS 8.x (#615) To support iOS < 9.0 and macOS < 10.11, NotificationCenter observers **must** be properly removed, or a crash may result. * Fixes DelayProcedure thread-safety (#616) * Fixes to Location related procedures (#619) * Capability.Location should set its registrar's delegate to nil on deinit. CLLocationManager’s delegate is `unowned(unsafe)`, and we must ensure it is set to nil before the object goes away. The only strong reference to the delegate that Capability.Location sets is stored within Capability.Location. * LocationCapabilityTests tweaks Explicitly set the test CLLocationManager’s `delegate` back to nil. Explicitly wait on `capability.requestAuthorization` to fulfill an expectation. * ReverseGeocodeProcedureTests tweaks * Fix an occasional crash running the Location tests It seems there may be an edge case in CoreLocation triggered when creating (and releasing) lots of CLLocationManager instances (as previously happened when each test, using its own TestableLocationServicesRegistrar, created a “fake” CLLocationManager). Change `TestableLocationServicesRegistrar`’s “fake” CLLocationManager (which is only used to populate a parameter in the delegate callbacks) to a static class variable. * Compiles out SystemConfiguration related stuff from watchOS (#621) * Adds an All subspec (#623) * Adds missing imports in TestingProcedureKit (#625) Noticed this issue after doing some integration testing via CocoaPods * Network*Procedure tweaks (#626) * Resolve cancellation race condition in Network*Procedure Must check `!isCancelled` inside the `stateLock`, or it is possible for a `NetworkDataProcedure`/`NetworkDownloadProcedure`/`NetworkUploadProcedur e` that is cancelled after the `execute()` function is called, but before the acquisition of the `stateLock` inside it, to continue to create a network task. * Mark `task` as `private(set)` The `task` variable should not be set outside of the `NetworkDataProcedure` / `NetworkDownloadProcedure` / `NetworkUploadProcedure`. * Memory leaks fixes highlighted by Visual Memory Debugger (#624) * TimeoutObserver should capture a weak reference to the procedure * RetryIterator should not maintain a strong reference to the RetryProcedure RetryIterator’s RetryFailureInfo (`info`) property is set right before `addNextOperation()` is called, which calls `next()` on the RetryIterator (which then uses the RetryFailureInfo). Ultimately, the RetryFailureInfo contains strong references to the RetryProcedure. And since the RetryProcedure owns the RetryIterator, which owns the RetryFailureInfo… We end up with a reference cycle. As an immediate quick fix, since the RetryFailureInfo is only used in the call to `addNextOperation()`, set it back to `.none` after the call. * Add test to catch reference cycles in RetryProcedure (Fixed by prior commit.) * GroupProcedure: ensure that internal queue is emptied on deinit Previously, a GroupProcedure that was created and released but never added to a queue would leak the child operations on its internal OperationQueue. To ensure that it is safe to release a GroupProcedure in all circumstances, add a `deinit` handler that explicitly cancels all operations on the queue, and also ensures that the queue is not suspended (so the queue will handle the clean-up). * Revert "GroupProcedure: ensure that internal queue is emptied on deinit" This reverts commit f2b7176fc8a96e841c8829f8d3b903633c50e883. * GroupProcedure: ensure that internal queue is emptied on deinit Previously, a GroupProcedure that was created and released but never added to a queue would leak the child operations on its internal OperationQueue. To ensure that it is safe to release a GroupProcedure in all circumstances, add a `deinit` handler that explicitly cancels all operations on the queue, and also ensures that the queue is not suspended (so the queue will handle the clean-up). * Procedure: Use an autoreleasepool in `start()` override Replicate the `NSOperation.start()` autorelease behavior by pushing an autoreleasepool before calling `main()`, and popping after `main()` returns. This is particularly important because we override the default `start()` and `main()` behavior, and our `main()` calls the Procedure subclass’s `execute()` (and we need to ensure that `execute()`, which is running on a background thread, has an autoreleasepool). * Resolves cancellation race condition in Network*Procedure (#627) The internal cancel observer should be a DidCancelObserver. * Adds step to CI for CocoaPod integration (#630) * [OPR-630]: Adds TryProcedureKit trigger * [OPR-630]: Sets the correct commit * [OPR-630]: Lowercase pipeline name * [OPR-630]: Fixes a pipeline typo * [OPR-630]: Renames cocoapods branch in TryProcedureKit * Fixes copy/paste typos (#634) Fixes #633. * Supports result injection in NetworkProcedure (#632) Closes #631. * [OPR-32]: Makes NetworkProcedure conform to OutputProcedure * [OPR-632]: Adds convenience API for injecting payload from network * [OPR-632]: Adds tests for injectPayload(fromNetwork:) * Removes the fatal override of waitUntilFinished() (#635) * Adds UIProcedure & AlertProcedure (#592) UIProcedure & AlertProcedure * ProcessProcedure improvements & thread-safety (#639) * Move ProcessProcedureTests to the "Mac Tests" group * ProcessProcedure thread-safety `NSTask`/`Process` is listed as a Thread-…
danthorpe
added a commit
that referenced
this pull request
Mar 29, 2017
* Will Cancel Observer (#293) * [OPR-293]: Refactors Start & Cancellation observers * [OPR-293]: Go back to original group cancellation policy * [OPR-293]: Adds errors to will cancel observer * [OPR-293]: Avoids overriding cancel Instead adds a will cancel observer. * [OPR-293]: Corrects mistake where the queue was not suspended !! * [OPR-293]: Makes cancel a final method This prevents Operation subclasses from overriding cancel. Instead, they should add an observer as appropriate. WillCancelObserver <- block is executed directly before the operation will change its cancellation state. DidCancelObserver <- block is executed directly after the operation did change its cancellation state. Typically, subclasses will want to observe WillCancel to update their own internal state. But consumers will want to observe DidCancel to respond to operations being cancelled. * [OPR-293]: Adds to new operations to property Also makes the queue private. * [OPR-293]: Cancels all operations in the queue. This will ensure that the finishing operation is also cancelled. * [OPR-293]: Adds will/did cancel API * [OPR-293]: Fixes some issues with GroupOperation One of the issues with adding the operations to the queue in the initializer, is that observers will not get notified. So, we have to add the initial operations in `execute`. But, if we append to operations in addOperations, that means, we need to filter out any instances which have already been added. For example, a subclass may well implement execute to first addOperation(myOperation); super.execute() which would cause a crash if we tried adding myOperation twice. * [OPR-293]: Renames will/didFinish This is to be consistent with operationWill/operationDidCancel * Conditions as Operations (#286) * [OPR-278]: Adds protocols for OperationType * [OPR-278]: Creates ConditionOperation With internal types for wrapping OperationCondition, and evaluating groups. * [OPR-278]: Initial work removing ready override. * [OPR-278]: Enables previously failing test * [OPR-278]: Adds missing files to Extension project * [OPR-278]: Enables previously failing test in iOS scheme too * [OPR-278]: Increases the batch size. Also removes the logging. * [OPR-278]: Fixes scheduling of dependencies. * [OPR-278]: Further fixes to dependency scheduling. * [OPR-278]: Removes unnecessary protocols * [OPR-278]: Removes dependency between evaluator and conditons This can introduce a deadlock with mutual exclusivity. * [OPR-278]: Fixes incorrect test with profiler. * [OPR-278]: Enables all tests on OS X * [OPR-278]: Enables all tests on iOS * [OPR-278]: Prevents a retain cycle in ConditionOperation * [OPR-278]: Adds failing test to clarify mutual exclusivity * [OPR-278]: Sets mutual exclusion around operation This was a mistake - it was getting set on the condition. * [OPR-278]: Fixes mutual exclusivity tests * [OPR-278]: Sorts out mutual conditions with dependencies Also, operations which have dependencies, and mutually exclusive conditions which have dependencies. * [OPR-278]: Clean up the code a bit * [OPR-278]: Includes indirect dependencies * [OPR-278]: Starts adding Stress Tests This is a new test bundle which gets tested as part of the OS X test suite. * [OPR-278]: Renames ConditionOperation to Condition It *is* an operation, but I want it to be treated like a Condition with it's own evaluate API * [OPR-278]: Sets up tests * [OPR-278]: Renames to mutuallyExclusive * [OPR-278]: Fixes target reference for Condition.swift * [OPR-278]: Adds ComposedCondition This is useful (and uses automatic result injection) for easily getting the result of a previous condition. * [OPR-278]: Refactors BlockCondition * [OPR-278]: Refactors NegatedCondition * [OPR-278]: Initial work on updating framework conditions - [x] BlockCondition - [x] TrueCondition - [x] FalseCondition - [x] ComposedCondition - [x] SilentCondition - [x] NegatedCondition - [x] MutuallyExclusive - [x] NoFailedDependenciesCondition * [OPR-278]: Corrects a mistake with removeDependencies We we actually just adding?! * [OPR-278]: Mixes the composed direct dependencies * [OPR-278]: Updates UserNotificationCondition to subclass Condition * [OPR-278]: Fixes some tests for iOS * [OPR-278]: Refactors AuthorizedFor * [OPR-278]: Refactors UserConfirmationCondition * [OPR-278]: Refactors ReachabilityCondition * [OPR-278]: Refactors AddressBookCondition * [OPR-278]: Refactors ContactsCondition * [OPR-278]: Refactors RemoteNotificationCondition * [OPR-278]: Adds @available annotation. Still not really sure how to accuractly mark API as deprecated inside a framework. * [OPR-278]: Adds some tests for conditions * [OPR-278]: Refactors condition error type * [OPR-278]: Refactors True False Condition * [OPR-278]: Cleans up Condition tests * [OPR-278]: Fixes tests * Fixes an incorrect Fix-It hint. (#302) Fixes #299. * Fixes notice severity logs (#303) This was done during development and accidentally committed & pushed. Fixes #300 * Fixes bug: CLLocationManager prematurely responds with 'NotDetermined' auth status when asking for permission (#305) * CLLocationAuthorizationStatus bug (#306) * Fixes bug: CLLocationManager prematurely responds with 'NotDetermined' auth status when asking for permission (#305) * [OPR-306]: Adds test coverage for location capability * Improved support for CloudKit Errors (#304) * [OPR-290]: Adds Error associated type on CKOperationType At the moment, this is just fulfilled by NSError, however it will allow us to offer specialized error responses depending on the operation. * [OPR-290]: Updates test cloud kit operation. * [OPR-290]: Adds missing file to Extension project * [OPR-290]: Moves CloudKit sources into a folder * [OPR-290]: Adds errors for Modify Zones & Records * [OPR-290]: Adds custom error types for all CloudKit Operations * [OPR-290]: Fixes error handling Now every CKOperation has it's own bespoke error type. * [OPR-290]: Tidies up AssociatedErrorType * [OPR-290]: Fixes issues with AssociatedErrorType * [OPR-290]: Adds error recovery to BatchedCloudKitOperation * [OPR-290]: Exposes properties on OPRCKOperation These are needed to configure operations inside error handlers. * Removes unnecessary let statement (#310) * Supports entersReaderIfAvailable configuration in WebpageOperation. (#312) It is possible now to show an SFSafariViewController with entersReaderIfAvailable set to false. * Refactors WebpageOperation to subclass ComposedOperation (#315) * Extended WebpageOperation with the ability to configure entersReaderIfAvailable at initialization. It is possible now to show an SFSafariViewController with entersReaderIfAvailable set to false. * Fixed a bug in WebpageOperation that that resulted in a retain cycle. * - Refactored WebpageOperation as ComposedOperation to fix a retain cycle. - Added Documentation. * Fixed some typos in WebpageOperationTests. * Implemented OpenInSafariOperation (#317) * Implemented OpenInSafariOperation * Made the displayControllerFrom non optional. * Refactored OpenInSafariOperation. * Fixes a bug removing dependencies on Condition (#309) The issue is that ComposedCondition must remove the dependency on its composed condition too. * Improves cancellation checks in main() (#319) * [OPR-287]: Invokes observers in main main() is called from start, and we already check that the operation is not cancelled. Therefore the check at the start of main is redundant. However, we don't check after the observers have been executed that the operation is cancelled. * [OPR-287]: SwiftLint fixes. * Exposes LogSeverity enum to Objective-C (#324) * Remove Reachability from CloudKitOperation (#327) * Ignore DS_Store * Rip out reachability from CloudKitOperation * [OPR-327]: Adds trailing closure syntax * [OPR-327]: Adds TimeoutObserver * [OPR-327]: Adds tests for timeout observer * Override NSOperationQueue's mainQueue() (#330) * Override NSOperationQueue's mainQueue() to return the main queue as an OperationQueue * set maxConcurrentOperationCount to 1 * Adds missing functionality of UIAlertController to AlertOperation (#334) * Added missing functionality of UIAlertController to AlertOperation. * Annotated new functionality as public. * Added test cases for new functionality. * Made alert property of AlertOperation private. * SwiftLint corrections. * Added a test for preferredAction and fixed a but related to it. * Made UserIntent enum objc accessbile (#341) * Fixed network observer flickering (#338) Added tests for multiple operations having network observer * Supports error recovery in GroupOperation (#326) * [OPR-326]: Adds Errors subtype in Operation * [OPR-326]: Refactors GroupOperation willFinish API * Revert "[OPR-326]: Adds Errors subtype in Operation" This reverts commit 759f2ef3643cafbbda3544185234b8adeec474ef. * [OPR-326]: WIP on group operation errors * [OPR-326]: Fixes issues with retry operation tests This is still not quite right. * [OPR-326]: Allows RetryOperation to fully recover from errors * [OPR-326]: Fixes issue with tests * [OPR-326]: Tweaks ProfilerTest case * [OPR-326]: Refactors ComposedOperation to just subclass GroupOperation * [OPR-326]: Changes behaviour when a group produces an operation * [OPR-326]: Logs when a GroupOperation successfully recovers from errors * [OPR-326]: Logs when the next operation will be added * [OPR-326]: Adds an immediate WaitStrategy * [OPR-326]: Adds the operation to the log when attempting recovery * [OPR-326]: Removes unneeded handling of child errors * [OPR-326]: Allows the WaitStrategy to be defined at init * [OPR-326]: Changes to support ComposedOperation * [OPR-326]: Speeds up CloudKit tests with .Immediate wait strategy * [OPR-326]: WIP on GroupOperation errors * [OPR-326]: Fixes a bug where operation would not retry In the case where there is a default handler, but no custom one set for the same error. * [OPR-326]: Renames internal methods to be more Swifty * [OPR-326]: Fixes errors - whoops. * Always create CLLocationManager on the main queue (#321) * [OPR-321]: Creates CLLocationManager on the main thread Also makes it thread safe. * [OPR-321]: Refactors capability to use guard & early exit. * [OPR-321]: Creates CLLocationManager lazily on the main thread Refactors UserLocationOperation to not use generic at the same time * [OPR-321]: Fixes deadlock in creating CLLocationManager * [OPR-321]: Refactors location operations for early exit * [OPR-321]: Removes use of NSThread to check for main queue * [OPR-321]: Fixes a mistake with the merge * RepeatedOperation allows for configuration block to be reset by the payload (#348) * [OPR-332]: Adds support for RetryOperation to provide a configuration block * [OPR-332]: Removes commented out code * [OPR-332]: Adds test to check that configure block is replaced * Turns on Whole Module Optimization (#350) Fixes #349 * Exposes the UIAlert for customization. (#351) This also fixes a bug where it wasn't possible to set a barButtonItem on an ActionSheet while presenting as a popover. * Fixes OperationQueue.delegate crash (SR-192) (#353) * Add failing test test__SR_192_OperationQueue_delegate_weak_var_thread_safety: Tests race condition (and crash) involving OperationQueue’s weak delegate var. * Fix for OperationQueue.delegate crash (SR-192) The underlying error is in Swift < 3.0, with concurrent reads of weak properties. See: https://bugs.swift.org/browse/SR-192 This change wraps the public delegate property with an NSLock. It also sets it to nil first-thing in deinit to safely get rid of it. * Simplistic support for CKLimitExceeded error handling (#294) * [OPR-294]: Initial work adding built in support for CKLimitExceeded * [OPR-294]: Rewrite with support for nil response * [OPR-294]: Adds support for adding error handlers in bulk * [OPR-294]: Fixes some comments * [OPR-294]: Moves error handling to CloudKitError * [OPR-294]: Adds BatchProcessErrorType This is only needed for CKMarkNotificationsOperation * [OPR-294]: Renames error protocols * [OPR-294]: Adds support for batch processing * [OPR-294]: Adds & Refactors for tests * [OPR-294]: Minor tweaks * [OPR-294]: Further tweaks * [OPR-294]: Fixes error in bisect * [OPR-294]: Adds API to replace the configure block outright * [OPR-294]: Fixes failing tests * [OPR-294]: Refactors stress tests condition * Adds TaskOperation (#355) * [OPR-313]: Adds TaskOperation * [OPR-313]: Adds more test coverage * [OPR-313]: Adds header documentation * Vastly improves thread safety in Operations (#358) * FIX: GroupOperation.operations contains the initial operations twice after beginning to execute. Cause: `GroupOperation.execute()` calls `GroupOperation.addOperations(operations)`, which then re-adds the operations back to the operations array. Solution: Added a private **`_addOperations()`** method to `GroupOperation` with an additional flag to override this behavior - used in `GroupOperation.execute()`. `addOperations()` now calls this private implementation method. * Operation.cancel(), Operation.finish() thread-safety - `Operation.cancel()` now acquires the stateLock. - `Operation.finish()` now acquires the stateLock. - `stateLock` is now NSRecursiveLock(). - var `Operation.cancelled` is thread-safe. - var `Operation.errors` is thread-safe. - Explicitly send KVO notifications on NSOperation keyPaths at the right times, avoiding lots of unnecessary notifications. - Removed “State” KVO notifications. (Previously used to trigger NSOperation isExecuting/isFinished notifications, which are now triggered explicitly.) - Added missing operationWillFinish() call to finish(). - operationDidFinish() now happens after the state has been set to .Finished. - `Operation.cancelWithError(errors)` now asserts if it’s called while the Operation is finishing or finished. * Operation.main() thread-safety, Operation.disableAutomaticFinishing - `Operation.main()` acquires the stateLock when appropriate. - `Operation.main()` manually sends the isExecuting NSOperation KVO notifications when setting executing state. - Added ability to disable Operation’s automatic calling of finish(), with `init(disableAutomaticFinishing: Bool)`. (Defaults to existing behavior - i.e. false.) * GroupOperation improvements (finish and thread-safety) - GroupOperation should only finish() after its children have finished. - `GroupOperation._addOperations()` acquires the stateLock. - `GroupOperation._addOperations()` cancels new child operations if the GroupOperation is cancelled. * RepeatedOperation.addNextOperation() must check cancelled - RepeatedOperation.addNextOperation() now checks cancelled status. * Added new cancellation-related tests * Added new GroupOperation tests * Added Operation KVO notification tests (for NSOperation keyPaths) * Fixed spurious commit * Handle more possible cases in Operation.main() - Check that the Operation is not already executing. - Check that the Operation has not been finished by a WillExecute observer (either directly or as a side-effect of something else). Added a test case that demonstrates this possibility. * Add missing super.init() calls * More GroupOperation cancelling fixes - Changed the internal WillCancelObserver to a DidCancelObserver to ensure that the cancelled state has been set prior to cancelling child operations. (This ensures that side-effects of propagating cancellation to child operations - like RepeatedOperation attempting to add the next operation - can safely check the cancelled status.) * GroupOperation should not call queue.cancelAllOperations() Calling queue.cancelAllOperations() also cancels the finishingOperation, which skips properly waiting until all other child operations are finished. Fixed test. * Added willProduceOperation method to OperationQueueDelegate, fix GroupOperation handling of child-produced operations Informational method only. This enables GroupOperation to add child-produced operations to its internal operations array, and thus cancel them when the GroupOperation is cancelled. Added tests. * GroupOperation should ignore queue delegate calls from other queues Added missing guard at the top of the queue delegate methods in GroupOperation. Added test to illustrate simple failure case this change covers. * Refactor lock usage in Operation.finish() and .cancel() - Refactor lock usage to hold the stateLock only when necessary or manipulating internal state, and *not* when sending KVO notifications or notifying observers. - Improvements and fixes to KVO Notification Tests. * Further refactor lock usage in Operation (.execute()) - Refactor lock usage in `Operation.execute()` to hold the stateLock only when necessary or manipulating internal state, and *not* when sending KVO notifications or notifying observers. * Add a number of new StressTests that previously failed/crashed New tests have support for a `batches` parameter. * Initial fix for Logging-related crashes (thread-safety issues) - `Operation._log` must not be a lazy var. From the Swift book: > If a property marked with the lazy modifier is accessed by multiple threads simultaneously and the property has not yet been initialized, there is no guarantee that the property will be initialized only once. For more: https://bugs.swift.org/browse/SR-1042 - `Operation.log` must be thread-safe. Initial fix involves capturing a copy of the logging context (settings + operationName) at the time of access of `Operation.log`, returning that captured context as a LoggerType, and surrounding access of .log with a Read/Write lock. - LogManager properties must be thread-safe. * Refactor lock usage in GroupOperation - var `GroupOperation.operations` is now thread-safe. - GroupOperation now utilizes a private CanFinishOperation to safely transition to executing the finishingOperation. (See code & comments.) - GroupOperation now has its own lock that is used sparingly to protect finishing state. - `GroupOperation._addOperation()` now utilizes the groupFinishLock. * Minor tweaks - `Operation.stateLock` should remain private. * SwiftLint clean-up * Refactor lock usage in GroupOperation - Refactor lock usage to hold the groupFinishLock only when necessary or manipulating internal state, and *not* when sending KVO notifications, notifying observers, or changing additionalOperations state (which might send KVO notifications or notify observers). * Clean-up - Remove asserts from `Operation.cancelWithErrors()`. Operation cancellation methods should be safe to call at any time without asserting. - Other minor tweaks. * Clean-up - Moved NSOperationKeyPaths to extension NSOperation.KeyPath enum. * Clean-up * Clean-up - Remove unneeded `self.` * Clean-up * Clarify docs & re-formatting * Add new inits to Queue (NSQualityOfService and qos_class_t) Per code review. * Clean-up of GroupOperation * Make Operation.cancel() final (#359) Per discussion in: https://github.com/danthorpe/Operations/pull/293 https://github.com/danthorpe/Operations/pull/358#discussion_r70167086 * Supports composing simple types for Result injection (#362) * [OPR-362]: Linting whitespace changes * [OPR-362]: Adds support for composing “executors” inside a final Operation type This is a convenience class to aid adoption of _Operations_ without requiring types to subclass Operation. Instead, classes only need to conform to Executor, and then can use the Execute class, which support cancellation, and result injection. * Supports async executors (#363) * Fixes a finished log message (#365) The "Operation Did finish" log was using the opposite logic for error logging * Group's internal queue is non-public; exposes appropriate properties (#361) * Make GroupOperation's internal queue non-public, and expose appropriate properties on GroupOperation - Make GroupOperation.queue ~private~internal. (So it can be tested.) - Expose appropriate run-time editable properties of the GroupOperation’s queue as properties on GroupOperation. Specifically: - public var maxConcurrentOperationCount: Int - public var suspended: Bool - public var qualityOfService: NSQualityOfService - Add tests. * [OPR-361]: Support underlying queue in Group * GatedOperation cancels composed operation when gate is closed (#377) * [OPR-377]: Adds early exit with guard * [OPR-377]: Refactors GatedOperation execute * [OPR-377]: Fixes typo * Result Injection protocol improvements (#378) * [OPR-378]: Updates result injection APIs * [OPR-378]: Adds unit tests * [OPR-378]: Removes unnecessary weak self capture * Fixes dependency gets added twice if it's direct & indirect (#379) * [OPR-379]: Adds a failing unit test * [OPR-379]: Makes indirect dependencies unique set * Removes TaskOperation from non-macOS platforms (#382) * Removes AlertPresentation mutual exclusion (#383) * Adds IgnoredCondition (#385) * Filters out indirect dependencies which have already been added (#386) * Fixes issues with ignored condition (#390) This means that conditions which are ignored mean that the attached operation does not execute, but also does not finish with an error. It’s a nicer use case than GatedOperation. This works by checking the OperationResult for .Ignored and then only cancel() instead of cancelWithError(). Note that if the operation also has .Failed(errors) condition result, in addition to .Ignored then the operation will still not run but this time with errors (as expected). Note that if the operation also has .Satisfied condition result, in addition to .Ignored then the operation will not run, but without errors. * NoFailedDependenciesCondition supports ignoring cancelled operations (#397) Fixes #396. * [OPR-396]: NoFailedDependenciesCondition support ignoring cancels * [OPR-396]: Refactors initializer * [OPR-396]: Renames the condition * Ability to add configuration to the next (retried) CloudKitOperation (#395) * Adds CloudKitOperation.setPrepareForRetryHandler() * Adds BatchedCloudKitOperation.setPrepareForNextOperationHandler() * Clean-up * Updated new APIs, added documentation -Simpler, cleaner, better APIs. -Added documentation and examples for the new APIs. * Add documentation for BatchedCloudKitOperation. * Updates project header (#399) * [OPR-399]: Updates the header * [OPR-399]: Updates the README to point to the new URL for header * Updates guidelines (#400) * [OPR-400]: Updates copyright holders to “ProcedureKit” * [OPR-400]: Adds a code of conduct * [OPR-400]: Fixes a markdown formatting issue * [OPR-400]: Adds CONTRIBUTING guidelines * [OPR-400]: Moves CONTRIBUTING to .github directory * [OPR-400]: Removes an empty section * [OPR-400]: Adds instruction on adding verbose logs. * [OPR-400]: Updates CONTRIBUTING guideline * [OPR-400]: Updates README too * [OPR-400]: Fixes some typos * Creates ProcedureKit project (#401) * [OPR-401]: Sets up ProcedureKit project * [OPR-401]: Adds ProcedureKitMobile This will cover iOS & watchOS * [OPR-401]: Adds ProcedureKitTV * [OPR-401]: Fixes Runtime Search Paths * [OPR-401]: Adds StressTests * [OPR-401]: Adds ProcedureKitMac * [OPR-401]: Enables code coverage on all testable schemes * [OPR-401]: Adds ProcedureKitCloud * [OPR-401]: Changes to module imports * [OPR-401]: Changes Cloud to latest deployment versions * ProcedureKit CI - Stage 1 (#403) * [OPR-403]: Changes Stress Tests to only run as part of the ProcedureKitMac scheme * [OPR-403]: Changes Cloud minimum target versions * [OPR-403]: Adds tests to CI - ProcedureKit macOS * [OPR-403]: Fixes Operations mac tests * [OPR-403]: Fixes Operations tests 2 * [OPR-403]: Fixes Swift version to 2.2 * [OPR-403]: Moves common scripts around * [OPR-403]: Updates scripts * [OPR-403]: Changes to the Fastlane name for mac * [OPR-403]: Updates build dependencies * [OPR-403]: Sets the correct destination platform * [OPR-403]: Updates scan invocation * [OPR-403]: Updates Fastfile * [OPR-403]: Trying to use which to find bundle * [OPR-403]: Using quotes * [OPR-403]: Adds setup first * [OPR-403]: Putting the whole setup into quotes * [OPR-403]: Attempting to add multiple lines to the command * [OPR-403]: Puts it all on one line * [OPR-403]: Adds more ProcedureKit steps * [OPR-403]: Fixes error in Stress Tests build settings * [OPR-403]: Pipline Uploads * [OPR-403]: Fixes pipelines * [OPR-403]: Uses pipeline upload correctly * [OPR-403]: Fixes error in mobile tests * [OPR-403]: Adds watchOS * [OPR-403]: Removes automatic code signing * [OPR-403]: Comments out watchOS builds * [OPR-403]: Adds TV * [OPR-403]: Removes ad-hoc code signing * [OPR-403]: Fixes Operations iOS * [OPR-403]: Sets iPhone Developer automatic code signing * [OPR-403]: Updates buildkite agent tags for iOS Simulator * [OPR-403]: Sets the development team in xcargs * [OPR-403]: Enables automatic code signing without a team set * [OPR-403]: Fixes issues with code signing settings for TV * [OPR-403]: Removes the development team * [OPR-403]: Puts everything into a single pipeline * [OPR-403]: Cleans up the pipeline * [OPR-403]: Sets personal team for mobile unit tests * [OPR-403]: Updates the Fastlane lane names * [OPR-403]: Adds a copy frameworks build phase * [OPR-403]: Removes copy files phase * [OPR-403]: Comments out problematic build jobs * [OPR-403]: Removes Operations CI jobs * ProcedureKit CI - Stage 2 (#404) * Update CI dependencies (#409) * [OPR-409]: Updates dependencies and enables pipeline * [OPR-409]: Fixes YML * [OPR-409]: Fully specifies the destination Starting to really not like Fastlane * [OPR-409]: Switches to iOS 10 simulators. * [OR-409]: Sets the developer directory * [OPR-409]: Removes tvOS for Mobile framework * [OPR-409]: Reorders the jobs * Add base types to ProcedureKit (#405) * [OPR-405]: Creates Procedure * [OPR-405]: Sets the Swift version * [OPR-405]: Cleans project * [OPR-405]: Changes to destination * [OPR-405]: Stops using Fastlane for testing macOS * [OPR-405]: Adds initial files for ProcedureQueue * [OPR-405]: Defines ProcedureObserver * [OPR-405]: Adds the default implementation of ProcedureObserver * [OPR-405]: Adds the rest of the observer protocols * [OPR-405]: Adds @available annotations * [OPR-405]: Adds block based observers * [OPR-405]: Adds Protector / DispatchQueue extension * [OPR-405]: Further updates to observers API * [OPR-405]: Adds extension to Operation This is for addCompletionBlock - but will be used for more stuff when we get into dependencies * [OPR-405]: Fixes lint issues * [OPR-405]: Adds Procedure protocol with AbstractProcedure * [OPR-405]: Starts interfaces in AbstractProcedure for execute & finish * [OPR-405]: Adds state transition * [OPR-405]: Refactors Procedure to be protocol based. * [OPR-405]: Adds most of the cancellaton functionality * [OPR-405]: Adds main implementation With a few TODOs * [OPR-405]: Fixes available renames * [OPR-405]: Changes AbstractProcedure back to Procedure * [OPR-405]: Adds Testing framework With TestProcedure class * [OPR-405]: Adds basic API to ProcedureTestCase * [OPR-405]: Updates dependencies * [OPR-405]: Commenting out non mac unit tests Run CI on iOS Simulators is basically impossible on beta version of Xcode. * [OPR-405]: Adds finishing and cancellation tests * [OPR-405]: Adds some finishing tests * Adds Logging (#428) * [OPR-428]: Adds LogSeverity * [OPR-428]: Adds logger * [OPR-428]: Updates logging stuff * [OPR-428]: Adds logging tests * Group (#430) * [OPR-430]: Adds Group * [OPR-430]: Adds initializers to Group * [OPR-430]: Adds add child API to Group * [OPR-430]: Corrects spelling * [OPR-430]: Adds finishing APIs to Group * [OPR-430]: Adds extension of unavailable APIs * [OPR-430]: Adds GroupObserverProtocol * [OPR-430]: Adds error handling and recovery to Group * [OPR-430]: Improves group observers API * [OPR-430]: Adds first group test * [OPR-430]: Adds some basic tests for Group * [OPR-430]: Adds more unit test for Group * [OPR-430]: More tests for group * Adds User Intent (#439) * [OPR-439]: Adds UserIntent to Procedure * [OPR-439]: Adds userIntent to Group * Stress Tests Phase 1 (#442) * [OPR-442]: Adds StressTestCase and completion block stress tests * [OPR-442]: Uses StressLevel directly. * [OPR-442]: Refactors the test case names * [OPR-442]: Refactors to remove StressTestCase Instead the stress function can be added to the base ProcedureKitTestCase * [OPR-442]: Adds group cancel stress test * [OPR-422]: Refactors group stress tests These are currently failing * [OPR-422]: Refactors schemes, as stress tests are run as part of Mac tests * [OPR-442]: Updates Stress Tests batches Uses intermediate BatchProtocol, and exposes a measure API. * [OPR-422]: Changes the active developer directory * [OPR-422]: Adds group child finishing order stress test * [OPR-422]: Fixes incorrect pipeline step * [OPR-422]: Adds more stress tests for Procedure * [OPR-422]: Fixes TestError mistake * [OPR-422]: Changes to use didCancelBlockObserver Instead of didFinishBlockObserver - there might be a subtle bug here. * [OPR-422]: Disables some checks - have identified that there is definitely an error in finishing logic * [OPR-422]: Moves stress tests to their own scheme * [OPR-422]: Adds stress fastlane * [OPR-422]: Trying to see how to trigger stress tests * [OPR-422]: Removing - * [OPR-422]: Changes the trigger to ProcedureKit * [OPR-422]: Add the pipeline update step back * [OPR-422]: Fixes yml * [OPR-422]: More changes to pipeline template * [OPR-422]: Fixes the slug This is case sensitive! * [OPR-422]: Triggers a different pipeline stress tests * [OPR-422]: Adds commit message to stress test build * [OPR-422]: Modifies measure to be a little quicker * [OPR-422]: Updates baselines with Mac Pro * [OPR-422]: Fixes mistake with finishing from cancel * Fix issue with newlines in pipeline upload (#445) * [OPR-445]: Removes message from upload script * [OPR-422]: Puts the commit back * Initial work on Result Injection (#446) * Adds Dependencies & Conditions (#429) * [OPR-429]: Adds Condition protocol and class * [OPR-429]: Adds conditions to procedure and queue * [OPR-429]: Adds tests for Conditions Also adds XCTAssertProcedure functions to make verifying Procedure behaviour more consistent. * [OPR-429]: Adds remaining unit tests for conditions Still got Ignored Condition to add * [OPR-429]: Fixes some documentation * [OPR-429]: Performs the stress tests in the same build * [OPR-422]: Adds stress tests for conditions * [OPR-429]: Adds IgnoredCondition * ProcedureKitError (#437) * [OPR-437]: Regorganized the Core group * [OPR-437]: Refactors Errors into ProcedureKitError * Completes Result Injection API test coverage (#447) * [OPR-447]: Sorts out ResultInjection * [OPR-447]: Completes result injection tests * Fixes Xcode 8 GM issues (#463) * BlockProcedure (#450) * [OPR-450]: Adds BlockProcedure * [OPR-450]: Adds unit tests for map and block procedures * [OPR-450]: Adds some stress tests for block procedure * [OPR-450]: Updates stress tests * [OPR-450]: Fixes Xcode 8 GM escaping issue * [OPR-450]: Papers over some possible issues with finishing. In many cases the `should finish after cancelling` logic is returning false. * [OPR-450]: Removes some excessive logging * [OPR-450]: Adjusts variation to 15% * Mutual exclusive conditions (#448) * [OPR-448]: Adds MutualExclusion * [OPR-448]: Adds support for adding dependencies for mutual exclusion * [OPR-448]: WIP on mutual exclusivity * [OPR-448]: Finishes off test cases for mutual exclusivity * [OPR-448]: Refactors add condition API to attach condition I want to make the API consistent - but not choose consistency over intent. So, `add(dependency: myDependency)` makes sense - as it signals that the dependency is already managed by some other queue/system. Where as for a Condition, we specifically _attach_ it to Procedure instance, and it does not (ideally should not) be managed outside the Procedure. So, I want the concept of “attaching conditions to procedures” to be the language which is used to describe the behaviour. * DelayProcedure (#449) * [OPR-449]: Adds delay procedure * [OPR-449]: Adds DelayProcedure tests * Renames Group to GroupProcedure (#468) * Adds ProcedureKit.podspec (#467) * Adds NegatedCondition (#471) * Adds SilentCondition (#472) * Procedure finishing fixes (#474) * Resolve finishing issues related to FinishingFrom. * Add StressTest that covers concurrent calls to finish() * Revert ProcedureKitTestCase expectation fulfillment back to the main queue. * Adds BlockCondition (#473) * Adds NoFailedDependenciesCondition (#470) * Adds TimeoutObserver (#475) * [OPR-475]: Adds TimeoutObserver * [OPR-475]: Fixes issues with TestProcedure It was not correctly delaying. * Procedure name and identity (#478) * [OPR-478]: Adds name and Identity * [OPR-478]: Fixes some failing tests * [OPR-478]: Fixes another failing name test * Adds BlockObserver (#480) * [OPR-480]: Adds BlockObserver * [OPR-480]: Tweaks to stress tests * Adds ComposedProcedure & GatedProcedure (#487) * RepeatProcedure (#488) * [OPR-488]: Initial work on RepeatProcedure * [OPR-488]: Adds remaining test coverage * RetryProcedure (#491) * [OPR-491]: Adds RetryProcedure * [OPR-491]: Unifies the generic init pattern for repeat and retry procedures * Adds support for Capabilities (#492) * [OPR-492]: Fixes incorrectly spelt protocol * [OPR-492]: Adds Capability Including CapabilityProtocol, GetAuthorizationStatus, Authorize, AuthorizedFor * Adds BackgroundObserver (#476) * [OPR-476]: Fixes stress tests * [OPR-476]: Adds BackgroundObserver * [OPR-476]: Gets the Mobile test suite working * [OPR-476]: Switches code coverage on * [OPR-476]: Adds missing callback This was causing a failing unit test * [OPR-476]: Removes unnecessary build phase * [OPR-476]: Finishes BackgroundObserver tests * [OPR-476]: Removes verbose logging in test case * Adds FilterProcedure (#496) * [OPR-496]: Adds FilterProcedure * [OPR-496]: Adds filter method for when Result is a sequence * Adds ReduceProcedure (#497) * [OPR-497]: Adds ReduceProcedure * [OPR-497]: Refactors Map, Filter adds FlatMap MapProcedure is really a TransformProcedure. MapProcedure and FilterProcedure are now simple subclasses of ReduceProcedure, along with FlatMapProcedure. * Adds NetworkObserver (#498) * [OPR-498]: Adds NetworkObserver Additionally, this updated ProcedureKitTestCase to automatically add async expectation fulfills around operations which might be produced by a procedure. * [OPR-498]: Refactors ProcedureKitTestCase slightly for Swift 3 conventions. * Adds Location.Capability (#499) * [OPR-499]: Adds ProcedureKitLocation framework * [OPR-499]: Supports sychronous dispatch onto the main queue This is safe to call if already on the main queue. * [OPR-499]: Adds Capability.Location * Adds UserLocationProcedure (#500) * [OPR-500]: Adds UserLocationProcedure * [OPR-500]: Removes unneeded error struct * [OPR-500]: Fixes issue with tvOS * Corrects minimum deployment targets (#503) Fixes #501 * [OPR-501]: Fixes issues with deployment versions * [OPR-501]: Setting tvOS to 9.2 * Adds ReverseGeocodeProcedure (#502) * [OPR-502]: Adds ReverseGeocodeProcedure * [OPR-502]: Adds ProcedureKitMobile as a build dependency * [OPR-502]: Fixes a mistake where macOS location tests were requiring iOS simulator * [OPR-502]: Uses gym to ensure iOS builds ProcedureKitMobile before testing Location * [OPR-502]: Use scan instead of gym This is a hack. I want to make sure that when we test ProcedureKitLocation on iOS we have build ProcedureKitMobile. * Adds ReverseGeocodeUserLocationProcedure (#504) * [OPR-504]: Adds/renames files * [OPR-504]: Adds ReverseGeocodeUserLocationProcedure * [OPR-504]: Rounds out the unit tests on ReverseGeocodeUserLocationProcedure * Makes procedures open where appropriate (#510) * Refactors BlockProcedure (#511) * Adds AnyProcedure (#516) * [OPR-516]: Removes import foundation This is done by the prefix header * [OPR-516]: Adds AnyProcedure * [OPR-516]: Uses the correct underlying queue throughout AnyProcedure * Fixes regression of failing release build (#518) * Renames AuthorizationStatusProtocol to AuthorizationStatus (#519) * Renames capability reated procedures (#520) * Renames attach(condition: Condition) to add (#521) * Adds Capability.CloudKit (#523) * [OPR-523]: Adds Capability.CloudKit * [OPR-523]: Enables CI builds for CloudKit stuff on iOS and tvOS * Adds ProcedureKitNetwork framework (#524) * [OPR-524]: Adds ProcedureKitNetwork framework * [OPR-524]: Adds Network to CI jobs * [OPR-524]: Renames Stress Tests job * [OPR-524]: Shares the network scheme * [OPR-524]: Imports Foundation instead of Cocoa * [OPR-524]: Forces Stress Tests onto a non-simulator agent * Adds NetworkDataProcedure (#525) * [OPR-525]: Adds NetworkDataProcedure * [OPR-525]: Fixes up some unit tests * [OPR-525]: Adds missing test coverage * Moves TestableNetwork into TestingProcedureKit framework (#526) * Refactors injectDependency API to be an extension on ProcedureProtocol instead. (#527) * Adds transform block result injection API (#528) * [OPR-528]: Refactors result injection Uses an intermediatory injectResult(from: via:) API, which allows the caller to provide a throwing block to transform the result into the requirement. * [OPR-528]: Removes unneeded return * [OPR-528]: Fixes error in ProcedureKitLocation * Adds default empty implementations some queue delegate methods (#531) Only added the will-do-something ones. Fixes #530 * Adds space in the repo for presentations (#533) * [OPR-533]: Adds CocoaHeads Stockholm talk Contact @danthorpe if you want the original Keynote file. * [OPR-533]: Adds Sky-UK iOS Community Talk * [OPR-533]: Adds a presentations README * Disables the log for AnyProcedure (#534) * Fixes bug where GroupProcedure collects errors from children after its been cancelled (#532) * [OPR-532]: Adds failing test * [OPR-532]: Checks cancelled state of the group We can exit this delegate callback early if the group has already been cancelled. * [OPR-532]: Removes default implementation of willFinish It seems that adding default implementations here causes some odd behaviour / intermittent crash where this is overwritten in the QueueDelegate. * [OPR-532]: Fixes a unit test which is now mis-counting errors. * Adds .then { } API (#536) * [OPR-176]: Adds then extension on Operation * [OPR-176]: Implements .then { } API * [OPR-176]: Adds enqueue method to a collection of Operations * [OPR-176]: Fixes header docs * Removes default argument for session in NetworkDataProcedure (#538) * Tweaks the cancel block procedure stress tests (#539) There might be an underlying issue. As normally a batch of 10_000 finishing in ~ 5 seconds. But sometimes fails because it times out, meaning that an expectation is not getting fulfilled. * Moves ProcedureKit imports to umbrella headers (#540) * [OPR-540]: Putting the appropriate imports into umbrella headers * [OPR-540]: Fixing issues with importing ProcedureKit into TestingProcedureKit * Updates ProcedureKit podspec with subspecs (#508) * [OPR-508]: Lints podspec without an warnings or errors. * [OPR-508]: Fixes errors running tests * Adds ResilientNetworkProcedure (#537) * [OPR-537] Adds ResilientNetworkProcedure * [OPR-537]: Updates retry request with error code * [OPR-537]: Adds edge case for ResilientNetworkProcedure In some situations, the HTTP status code might well require (depending on the behaviour) a retry. * [OPR-537]: Fixes simple unit tests * Refactor ResultInjection to use PendingValue enum (#541) * [OPR-541]: Refactors ResultInjectionProtocol to use PendingValue enum * [OPR-541]: Renames ResultInjectionProtocol to ResultInjection * Fixes BlockProcedure stress tests (#544) * [OPR-544]: Fix test__cancel_block_procedure() failures It was possible for the testing BlockProcedure to finish prior to the `block.cancel()` call, which would result in some of the BlockProcedures never cancelling (as they had finished first), and a failing test. Fixed by using a semaphore inside the BlockProcedure’s block. Additionally, the test now waits for all BlockProcedures to cancel *and* finish. * [OPR-544]: Added a new stress test for BlockProcedure cancelling & finishing behavior (allowing for possible races between cancelling and finishing) * Fixes ExclusivityManager synchronization bug (#545) Fixes #543 The ExclusivityManager was using `DispatchQueue.initiated`, which returns a global **concurrent** queue, however its internals are dependent upon **serial** execution of add/remove. Modified to use a serial queue. * Adds ResultProcedure and overloads injectResult(from:) (#546) * Adds HTTPResult<Payload> (#547) * Fix test crashes caused by QueueTestDelegate (#549) QueueTestDelegate was not thread-safe. This could result in crashes running random tests. Fixed by making QueueTestDelegate’s methods thread-safe. * Adds ProcedureKitTestCase wait function that takes an array (#552) * Adds TestingProcedureKit podspec (#553) * Adds Mutual Exclusivity concurrency testing (#550) * Add ConcurrencyTestCase Exposes functionality to test operation concurrency. * Add Mutual Exclusivity concurrency tests * Refactored ConcurrencyTestCase * Refactored ConcurrencyTestCase * Adds didExecuteObserver (#554) * [OPR-554]: Adds code with failing test * [OPR-554]: Calls didExecuteObservers * [OPR-554]: Fixes a typo * [OPR-554]: Adds some documentation to the DidExecuteObserver * Fixes mistake in Fastfile (#557) * [OPR-557]: Fixes error in Fastfile * [OPR-557]: Removes duplicate scan I remember now, as part of location, we used to build Mobile too - because there was a dependency on iOS. But this has since been removed. * Fixes release configuration issues with Xcode 8.1 (#559) Fixes #548 * [OPR-548]: Fixes issue with Xcode 8.1 release configuration * [OPR-548]: Fixes some SwiftLint warnings. * [OPR-548]: Fixes Xcode project warnings in Xcode 8.1 * Adds GroupProcedure concurrency tests (#556) * Add GroupConcurrencyTestCase * Add GroupProcedure.maxConcurrentOperationCount tests * Fixes registrar typo (#562) * Adds NetworkDownloadProcedure. (#565) The implementation for class and test is largely inspired by `NetworkDataProcedure` class. * Adds NetworkUploadProcedure. (#567) * Add NetworkUploadProcedure. The implementation class and test has been largely inspired by `NetworkDataProcedure`. The requirement type is currently a pending value of a tuple. Maybe would it make more sense to create a dedicated struct to add more clarity in the case of dependencies injection ? * Use an `HTTPRequirement` struct for requirement. As discussed, an `HTTPRequirement` struct is used instead of a tuple. * Fixes Condition to support ResultInjection (#566) * [OPR-566]: Replaces Condition result with PendingValue<ConditionResult> * [OPR-566]: Refactors how conditions are evaluated This fixes a existing issue where the ConditionEvaluation enum was basically just like ConditonResult, except that it could hold an array of errors. This has been resolved by using an internal error type `ProcedureKitError.FailedConditions` to collect multiple errors from failed conditons, so that we can reduce a sequence of `ConditionResult`s into a single one. * [OPR-566]: Explicitly adds a Result typealias * [OPR-566]: Fixes error where cancelled conditions would throw a fatal error. * [OPR-566]: Removes verbose log * Adds ProcessProcedure. (#570) * Add ProcessProcedure. The class has been largely inspired by the original `TaskOperation`. Refers to #568. * Apply requested changes. Correctly implement `Equatable` for sub-error enum. Use camel case for the enum. Fix closure self semantics. * Calls TestableReverseGeocoder completionHandler on the main queue (#572) * Improves performance of adding observers * Procedure.add(observer:) performance tweak Append directly to the protected observers array. * Fix swiftlint `variable_name` warning * Makes ProcedureQueue.add(operation: Operation) method open (#578) * Fixes NetworkObserver thread-safety (#576) (#577) * Fix NetworkObserver thread-safety By fixing NetworkActivityController `start()`/`stop()` thread-safety. (And making private methods/variables private.) * NetworkObserver test fixes * Reduce test delay * Additional GroupProcedure tests (#579) * Adds CloudKitProcedure (#542) * [OPR-542]: Adds shell of CloudKit files * [OPR-542]: Adds extensions for CKOperation * [OPR-542]: Adds extensions for CKDatabaseOperation * [OPR-542]: Adds extensions for CKAcceptSharesOperation * [OPR-542]: Adds extensions for CKDiscoverAllContactsOperation * [OPR-542]: Adds extensions for CKDiscoverAllUserIdentifiesOperation * [OPR-542]: Adds extensions for CKDiscoverUserIdentitiesOperation * [OPR-542]: Adds extensions for CKDiscoverUserInfosOperation * [OPR-542]: Adds extensions for CKFetchDatabaseChanges * [OPR-542]: Adds extensions for CKFetchDatabaseChangesOperation * [OPR-542]: Adds extensions for CKFetchRecordChangesOperation * [OPR-542]: Moves the interface into the extension files * [OPR-542]: Fixes dispatchQueue * [OPR-542]: Adds extensions to CKFetchRecordsOperation * [OPR-542]: Adds extensions for CKFetchRecordZoneChangesOperation * [OPR-542]: Removes unnecessary public properties * [OPR-542]: Adds extensions for CKFetchRecordZonesOperation * [OPR-542]: Adds extensions for CKFetchShareMetadataOperation * [OPR-542]: Adds extensions for CKFetchShareParticipantsOperation * [OPR-542]: Adds extensions for CKFetchSubscriptionsOperation * [OPR-542]: Adds extensions for CKMarkNotificationsReadOperation * [OPR-542]: Adds extensions for CKModifyBadgeOperation * [OPR-542]: Adds extensions for CKModifyRecordsOperation * [OPR-542]: Adds extensions for CKModifyRecordZonesOperation * [OPR-542]: Adds extensions for CKModifySubscriptionsOperation * [OPR-542]: Adds extensions for CKQueryOperation * [OPR-542]: Adds missing APIs for error handlers * [OPR-542]: Adds testable CK operation classes * [OPR-542]: Adds tests for CKOperation, CKDatabaseOperation and CKAcceptSharesOperation * [OPR-542]: Removes missing test cases from tvOS * Small typo fix * Adds tests for CKDiscoverAllContactsOperation * Adds tests for CKDiscoverAllUserIdentitiesOperation * Adds tests for CKDiscoverUserIdentitiesOperation * Adds tests for CKDiscoverUserInfosOperation * [OPR-542]: Adds tests for CKFetchAllChanges protocol * [OPR-542]: Adds tests for CKFetchDatabaseChangesOperation * [OPR-542]: Adds tests for CKFetchNotificationChangesOperation * [OPR-542]: Adds tests for CKFetchRecordChangesOperation * [OPR-542]: Adds tests for CKFetchRecordsOperation * [OPR-542]: Added missing `recordZoneFetchCompletionBlock` for CKFetchRecordZoneChangesOperationProtocol extensions * [OPR-542]: Adds tests for CKFetchRecordZoneChangesOperation * [OPR-542]: Adds tests for CKFetchRecordZonesOperation * [OPR-542]: Adds tests for CKFetchShareMetadataOperation * [OPR-542]: Adds tests for CKFetchShareParticipantsOperation * [OPR-542]: Adds tests for CKFetchSubscriptionsOperation * [OPR-542]: Minor typo fix To follow the original API naming, change `setMarkNotificationReadCompletionBlock` to `setMarkNotificationsReadCompletionBlock`. * [OPR-542]: Adds tests for CKMarkNotificationsReadOperation * [OPR-542]: Adds tests for CKModifyBadgeOperation * [OPR-542]: Adds tests for CKModifyRecordsOperation * [OPR-542]: Adds tests for CKModifyRecordZonesOperation * [OPR-542]: Adds tests for CKModifySubscriptionsOperation * [OPR-542]: Adds tests for CKQueryOperation * [OPR-542]: Fixes whitespace in test cases * [OPR-542]: Adds CloudKitProcedure<CKAcceptSharesOperation> tests * [OPR-542]: Fixes tests on tvOS. Again. * [OPR-542]: Adds tests for CKDiscoverAllContactsOperation * [OPR-542]: Adds tests for CKDiscoverAllUserIdentitiesOperation * [OPR-542]: Adds tests for CKDiscoverUserIdentitiesOperation * [OPR-542]: Adds tests for CKDiscoverUserInfosOperations * [OPR-542]: Adds tests for CKFetchDatabaseChangesOperation * [OPR-542]: Unifies testing of common properites * [OPR-542]: Adds tests for CKFetchNotificationChangesOperation * [OPR-542]: Adds tests for CKFetchRecordChangesOperation * [OPR-542]: Adds test for CKFetchRecordsOperation * [OPR-542]: Adds tests for CKFetchRecordZoneChangesOperation * [OPR-542]: Adds test for CKFetchRecordZonesOperation * [OPR-542]: Adds tests for CKFetchShareMetadataOperation * [OPR-542]: Adds tests for CKFetchShareParticipantsOperation * [OPR-542]: Fixes inconsistently named tests * [OPR-542]: Adds tests for CKFetchSubscriptionsOperation * [OPR-542]: Adds tests for CKMarkNotificationsReadOperation * [OPR-542]: Adds tests for CKModifyBadgeOperation * [OPR-542]: Adds tests for CKModifyRecordsOperation * [OPR-542]: Adds tests for CKModifyRecordZonesOperation * [OPR-542]: Adds test for CKModifySubscriptionsOperation * [OPR-542]: Adds test for CKQueryOperation * [OPR-542]: Adds tests which trigger default retry behavior * [OPR-542]: Adds tests for set/get all errors handlers * [OPR-542]: Adds tests for custom error handlers * Adds Profiler (#573) * Implement Profiler as specified in #569. The implmentation is largely inspired by the original `Profiler.swift` file. * Add first set of tests. The test has been largely inspired by the original tests classes. I have a commented test taht fails. After trying to debug for a while, I suspect maybe an issue inside GroupProcedure or the original implementation. * Apply requested changes. Perform changes as requested. * Adds public initialiser to HTTPRequirement (#586) Declaring a constructor for the `HTTPRequirement` allows the construction of the struct without any issue. * Removes GroupProcedureObserver protocol (#583) Instead ProcedureObserver takes over this responsibility. * [OPR-574]: Cleans up white space & style for consistency * [OPR-574]: Uncomments failing test * [OPR-574]: Adds new API to ProcedureObserver protocol * [OPR-574]: Removes temporary print statements * [OPR-574]: Refactors to support willAdd & didAdd observer callbacks. * [OPR-574]: Removes commented out line. * [OPR-574]: Removes group observers. * [OPR-574]: Removes extraneous logging in some tests * [OPR-574]: Makes add(observer:) open for overriding * [OPR-574]: Adds some documentation comments to public interfaces * Supports Arbitrary mutual exclusion category names (#587) Fixes #580. * [OPR-580]: Supports arbitrary mutual exclusion category names * [OPR-580]: Fixes default category for AuthorizedFor * Adds NetworkReachableProcedure (#563) * [OPR-563]: Adds Reachability functionality * [OPR-563]: Adds additional files for testing support * [OPR-563]: Adds tests for Reachability * [OPR-563]: Adds basis of NetworkReachableProcedure * [OPR-563]: Adds simple network reachability procedure tests * [OPR-563]: Fixes issue with Protector write being synchronous. * [OPR-563]: Refactors DeviceReachability slightly * [OPR-563]: Changes Protector behavior back to be non-blocking * [OPR-563]: Fixes Reachability.Device * [OPR-563]: Adds NetworkProcedure and ProcedureKitNetworkError * [OPR-563]: Fixes for network error tests * [OPR-563]: Adds remaining tests for Reachable procedure * [OPR-563]: Removes unnecessary logging * Refactors produce API (#588) * Add failing test * Test tweaks * Changes to Procedure.produce(operation:) handling Fixes failing test case, and simplifies execution flow. Changes `willEnqueue()` to `willEnqueue(on: ProcedureQueue)`. `func produce(operation: Operation)` now throws. * Ported additional test case from Operations 3.x. * swiftlint tweak * Fixed mobile tests. * Adds missing equality cases for ProcedureKitError.Context (#591) Fixes #589 * Supports merging collections of ResultInjection Procedures (#593) * [OPR-593]: Adds gather and reduce APIs * [OPR-593]: Removes the rethrows While the nextPartialResult closure can throw, this error is not re-thrown. Instead, because this block is executed after the receiver’s procedures have all finished, the error means that the `ResultProcedure` will finish with an error. * [OPR-593]: Adds test case for throwing closure * [OPR-593]: Refactors gather() so that it is a specialization of new flatMap API * Improves how stress tests are run in CI (#594) * [OPR-594]: Updates pipeline queues * [OPR-594]: Fixes yaml * [OPR-594]: Disables Thread Sanitizer for Stress Tests * [OPR-594]: Uses Release configuration for stress tests * Fix StressTestCase Batch counters thread-safety (#555) (#596) * Fixes public access levels for CKProcedure (#599) * Fixes some RepeatProcedure thread-safety issues (#597) Fix issues identified by an audit and Thread Sanitizer * Fixes Procedure & Support thread-safety (#598) * Change Protector.write() to be synchronous (and optionally return a value from the block) Thread Sanitizer identified a data race caused by the combination of the prior asynchronous `write()` and deinitialization. * Explicitly `import Dispatch` in Support.swift Fixes an occasional Xcode warning display glitch. * Fix Protector.read() to no longer require an `escaping` block * Adds back `Protector.write(_:completion:)` Although, like the new write(_:) method, this is now synchronous. * Wrap all properties of Procedure in a Protector to ensure thread-safety `errors`, `observers`, `directDependencies`, `conditions` (and associated methods) are now thread-safe * Fix comment formatting * Removes @testable import (#600) Exposes NSLock and NSRecursiveLock extensions * Add RepeatProcedure cancellation stress test (#602) * Adds more GroupProcedure test coverage (#603) * Additional / improved GroupProcedure test cases * Remove unused private setter * Refactors of Result Injection APIs (#601) * [OPR-601]: Renamed PendingResult to PendingProfileResult * [OPR-601]: Adds protocols for Input & Output * [OPR-601]: Refactors for InputProcedure & OutputProcedure * [OPR-601]: Refactors ReduceProcedure as a TransformProcedure subclass * [OPR-601]: Refactoring for InputProcedure & OutputProcedure * [OPR-601]: Refactoring Condition to use Result<Bool> * [OPR-601]: Refactors ProcedureKitNetwork result injection * [OPR-601]: Refactors Location for result injection * [OPR-601]: Removes ResultInjection.swift * [OPR-601]: Removes left over properties * [OPR-601]: Tidies up ResultProcedure & TransformProcedure * [OPR-601]: Adds finish(withResult:) API * [OPR-601]: Refactors to use finish(withResult:) * [OPR-601]: Renames HTTPRequirement & HTTPResult * Renames Result to ProcedureResult (#605) * [OPR-605]: Renames Result to ProcedureResult Just to help with any interop issues with antitypical/Result * [OPR-605]: Renames Result to ProcedureResult * Adds AsyncBlockProcedure (#606) * [OPR-606]: Adds AsyncBlockProcedure As a specialization of AsyncResultProcedure * [OPR-606]: Moves async block tests into same file * [OPR-606]: Adds AsyncTransformProcedure * Adds @escaping marker to the FinishingBlock (#607) * Fixes NetworkActivityController internal timer (#608) * NetworkActivityController's delayed hide should occur on the queue Fixes data race. * Remove outdated test * NetworkDataProcedure, NetworkDownloadProcedure, NetworkUploadProcedure thread-safety (#609) * Adds NetworkProcedure (#561) * [OPR-561]: Refactoring ResilientNetworkProcedure - Supports request timeout - Adds HTTPStatusCode where we only even consider retrying client or server errors. - Adds some initial tests * [OPR-561]: Refactors NetworkResilience * [OPR-561]: Refactor to unify reachable & resilience network procedures * [OPR-561]: Adds resilience error handling support This is so that even if the network request “succeeds” but results in say, a server error, we will still trigger retries. * [OPR-561]: Fixes typos * Add missing imports to make Xcode happier (#611) * Add explicit imports to the top of ProcedureKit files This makes Xcode happier. * Add missing imports to the top of ProcedureKitCloud files This makes Xcode happier. * Add missing imports to the top of ProcedureKitMobile files This makes Xcode happier. * Add missing imports to the top of ProcedureKitLocation files This makes Xcode happier. * Fixes BackgroundObserver data race (#614) * Makes NetworkObserver cross-platform (#613) * NetworkObserver and NetworkActivityController cross-platform work On all platforms, the following initializers are available: `NetworkObserver.init(controller: NetworkActivityController)` `NetworkActivityController.init(timerInterval: TimeInterval = 1.0, indicator: NetworkActivityIndicatorProtocol)` To implement your own network activity indicator display, conform to `NetworkActivityIndicatorProtocol`. NetworkActivityController ensures that all accesses of the indicator’s `networkActivityIndicatorVisible` property are serialized on the main queue. On iOS (but *not* in application extensions), the following convenience initializers are available that utilize `UIApplication.shared` to display/hide the network activity indicator in the status bar: `NetworkObserver.init()` `NetworkActivityController.init(timerInterval: TimeInterval = 1.0)` `NetworkActivityController.shared` * [OPR-612]: Moves NetworkObserver into Network framework * [OPR-612]: Moves NetworkObserver into ProcedureKit Keeps iOS non-extension related elements in ProcedureKitMobile * Add documentation * Fixes BackgroundObserver on iOS 8.x (#615) To support iOS < 9.0 and macOS < 10.11, NotificationCenter observers **must** be properly removed, or a crash may result. * Fixes DelayProcedure thread-safety (#616) * Fixes to Location related procedures (#619) * Capability.Location should set its registrar's delegate to nil on deinit. CLLocationManager’s delegate is `unowned(unsafe)`, and we must ensure it is set to nil before the object goes away. The only strong reference to the delegate that Capability.Location sets is stored within Capability.Location. * LocationCapabilityTests tweaks Explicitly set the test CLLocationManager’s `delegate` back to nil. Explicitly wait on `capability.requestAuthorization` to fulfill an expectation. * ReverseGeocodeProcedureTests tweaks * Fix an occasional crash running the Location tests It seems there may be an edge case in CoreLocation triggered when creating (and releasing) lots of CLLocationManager instances (as previously happened when each test, using its own TestableLocationServicesRegistrar, created a “fake” CLLocationManager). Change `TestableLocationServicesRegistrar`’s “fake” CLLocationManager (which is only used to populate a parameter in the delegate callbacks) to a static class variable. * Compiles out SystemConfiguration related stuff from watchOS (#621) * Adds an All subspec (#623) * Adds missing imports in TestingProcedureKit (#625) Noticed this issue after doing some integration testing via CocoaPods * Network*Procedure tweaks (#626) * Resolve cancellation race condition in Network*Procedure Must check `!isCancelled` inside the `stateLock`, or it is possible for a `NetworkDataProcedure`/`NetworkDownloadProcedure`/`NetworkUploadProcedur e` that is cancelled after the `execute()` function is called, but before the acquisition of the `stateLock` inside it, to continue to create a network task. * Mark `task` as `private(set)` The `task` variable should not be set outside of the `NetworkDataProcedure` / `NetworkDownloadProcedure` / `NetworkUploadProcedure`. * Memory leaks fixes highlighted by Visual Memory Debugger (#624) * TimeoutObserver should capture a weak reference to the procedure * RetryIterator should not maintain a strong reference to the RetryProcedure RetryIterator’s RetryFailureInfo (`info`) property is set right before `addNextOperation()` is called, which calls `next()` on the RetryIterator (which then uses the RetryFailureInfo). Ultimately, the RetryFailureInfo contains strong references to the RetryProcedure. And since the RetryProcedure owns the RetryIterator, which owns the RetryFailureInfo… We end up with a reference cycle. As an immediate quick fix, since the RetryFailureInfo is only used in the call to `addNextOperation()`, set it back to `.none` after the call. * Add test to catch reference cycles in RetryProcedure (Fixed by prior commit.) * GroupProcedure: ensure that internal queue is emptied on deinit Previously, a GroupProcedure that was created and released but never added to a queue would leak the child operations on its internal OperationQueue. To ensure that it is safe to release a GroupProcedure in all circumstances, add a `deinit` handler that explicitly cancels all operations on the queue, and also ensures that the queue is not suspended (so the queue will handle the clean-up). * Revert "GroupProcedure: ensure that internal queue is emptied on deinit" This reverts commit f2b7176fc8a96e841c8829f8d3b903633c50e883. * GroupProcedure: ensure that internal queue is emptied on deinit Previously, a GroupProcedure that was created and released but never added to a queue would leak the child operations on its internal OperationQueue. To ensure that it is safe to release a GroupProcedure in all circumstances, add a `deinit` handler that explicitly cancels all operations on the queue, and also ensures that the queue is not suspended (so the queue will handle the clean-up). * Procedure: Use an autoreleasepool in `start()` override Replicate the `NSOperation.start()` autorelease behavior by pushing an autoreleasepool before calling `main()`, and popping after `main()` returns. This is particularly important because we override the default `start()` and `main()` behavior, and our `main()` calls the Procedure subclass’s `execute()` (and we need to ensure that `execute()`, which is running on a background thread, has an autoreleasepool). * Resolves cancellation race condition in Network*Procedure (#627) The internal cancel observer should be a DidCancelObserver. * Adds step to CI for CocoaPod integration (#630) * [OPR-630]: Adds TryProcedureKit trigger * [OPR-630]: Sets the correct commit * [OPR-630]: Lowercase pipeline name * [OPR-630]: Fixes a pipeline typo * [OPR-630]: Renames cocoapods branch in TryProcedureKit * Fixes copy/paste typos (#634) Fixes #633. * Supports result injection in NetworkProcedure (#632) Closes #631. * [OPR-32]: Makes NetworkProcedure conform to OutputProcedure * [OPR-632]: Adds convenience API for injecting payload from network * [OPR-632]: Adds tests for injectPayload(fromNetwork:) * Removes the fatal override of waitUntilFinished() (#635) * Adds UIProcedure & AlertProcedure (#592) UIProcedure & AlertProcedure * ProcessProcedure improvements & thread-safety (#639) * Move ProcessProcedureTests to the "Mac Tests" group * ProcessProcedure thread-safety `NSTask`/`Process` is listed as a Thread-…
danthorpe
added a commit
that referenced
this pull request
Apr 8, 2017
* Will Cancel Observer (#293) * [OPR-293]: Refactors Start & Cancellation observers * [OPR-293]: Go back to original group cancellation policy * [OPR-293]: Adds errors to will cancel observer * [OPR-293]: Avoids overriding cancel Instead adds a will cancel observer. * [OPR-293]: Corrects mistake where the queue was not suspended !! * [OPR-293]: Makes cancel a final method This prevents Operation subclasses from overriding cancel. Instead, they should add an observer as appropriate. WillCancelObserver <- block is executed directly before the operation will change its cancellation state. DidCancelObserver <- block is executed directly after the operation did change its cancellation state. Typically, subclasses will want to observe WillCancel to update their own internal state. But consumers will want to observe DidCancel to respond to operations being cancelled. * [OPR-293]: Adds to new operations to property Also makes the queue private. * [OPR-293]: Cancels all operations in the queue. This will ensure that the finishing operation is also cancelled. * [OPR-293]: Adds will/did cancel API * [OPR-293]: Fixes some issues with GroupOperation One of the issues with adding the operations to the queue in the initializer, is that observers will not get notified. So, we have to add the initial operations in `execute`. But, if we append to operations in addOperations, that means, we need to filter out any instances which have already been added. For example, a subclass may well implement execute to first addOperation(myOperation); super.execute() which would cause a crash if we tried adding myOperation twice. * [OPR-293]: Renames will/didFinish This is to be consistent with operationWill/operationDidCancel * Conditions as Operations (#286) * [OPR-278]: Adds protocols for OperationType * [OPR-278]: Creates ConditionOperation With internal types for wrapping OperationCondition, and evaluating groups. * [OPR-278]: Initial work removing ready override. * [OPR-278]: Enables previously failing test * [OPR-278]: Adds missing files to Extension project * [OPR-278]: Enables previously failing test in iOS scheme too * [OPR-278]: Increases the batch size. Also removes the logging. * [OPR-278]: Fixes scheduling of dependencies. * [OPR-278]: Further fixes to dependency scheduling. * [OPR-278]: Removes unnecessary protocols * [OPR-278]: Removes dependency between evaluator and conditons This can introduce a deadlock with mutual exclusivity. * [OPR-278]: Fixes incorrect test with profiler. * [OPR-278]: Enables all tests on OS X * [OPR-278]: Enables all tests on iOS * [OPR-278]: Prevents a retain cycle in ConditionOperation * [OPR-278]: Adds failing test to clarify mutual exclusivity * [OPR-278]: Sets mutual exclusion around operation This was a mistake - it was getting set on the condition. * [OPR-278]: Fixes mutual exclusivity tests * [OPR-278]: Sorts out mutual conditions with dependencies Also, operations which have dependencies, and mutually exclusive conditions which have dependencies. * [OPR-278]: Clean up the code a bit * [OPR-278]: Includes indirect dependencies * [OPR-278]: Starts adding Stress Tests This is a new test bundle which gets tested as part of the OS X test suite. * [OPR-278]: Renames ConditionOperation to Condition It *is* an operation, but I want it to be treated like a Condition with it's own evaluate API * [OPR-278]: Sets up tests * [OPR-278]: Renames to mutuallyExclusive * [OPR-278]: Fixes target reference for Condition.swift * [OPR-278]: Adds ComposedCondition This is useful (and uses automatic result injection) for easily getting the result of a previous condition. * [OPR-278]: Refactors BlockCondition * [OPR-278]: Refactors NegatedCondition * [OPR-278]: Initial work on updating framework conditions - [x] BlockCondition - [x] TrueCondition - [x] FalseCondition - [x] ComposedCondition - [x] SilentCondition - [x] NegatedCondition - [x] MutuallyExclusive - [x] NoFailedDependenciesCondition * [OPR-278]: Corrects a mistake with removeDependencies We we actually just adding?! * [OPR-278]: Mixes the composed direct dependencies * [OPR-278]: Updates UserNotificationCondition to subclass Condition * [OPR-278]: Fixes some tests for iOS * [OPR-278]: Refactors AuthorizedFor * [OPR-278]: Refactors UserConfirmationCondition * [OPR-278]: Refactors ReachabilityCondition * [OPR-278]: Refactors AddressBookCondition * [OPR-278]: Refactors ContactsCondition * [OPR-278]: Refactors RemoteNotificationCondition * [OPR-278]: Adds @available annotation. Still not really sure how to accuractly mark API as deprecated inside a framework. * [OPR-278]: Adds some tests for conditions * [OPR-278]: Refactors condition error type * [OPR-278]: Refactors True False Condition * [OPR-278]: Cleans up Condition tests * [OPR-278]: Fixes tests * Fixes an incorrect Fix-It hint. (#302) Fixes #299. * Fixes notice severity logs (#303) This was done during development and accidentally committed & pushed. Fixes #300 * Fixes bug: CLLocationManager prematurely responds with 'NotDetermined' auth status when asking for permission (#305) * CLLocationAuthorizationStatus bug (#306) * Fixes bug: CLLocationManager prematurely responds with 'NotDetermined' auth status when asking for permission (#305) * [OPR-306]: Adds test coverage for location capability * Improved support for CloudKit Errors (#304) * [OPR-290]: Adds Error associated type on CKOperationType At the moment, this is just fulfilled by NSError, however it will allow us to offer specialized error responses depending on the operation. * [OPR-290]: Updates test cloud kit operation. * [OPR-290]: Adds missing file to Extension project * [OPR-290]: Moves CloudKit sources into a folder * [OPR-290]: Adds errors for Modify Zones & Records * [OPR-290]: Adds custom error types for all CloudKit Operations * [OPR-290]: Fixes error handling Now every CKOperation has it's own bespoke error type. * [OPR-290]: Tidies up AssociatedErrorType * [OPR-290]: Fixes issues with AssociatedErrorType * [OPR-290]: Adds error recovery to BatchedCloudKitOperation * [OPR-290]: Exposes properties on OPRCKOperation These are needed to configure operations inside error handlers. * Removes unnecessary let statement (#310) * Supports entersReaderIfAvailable configuration in WebpageOperation. (#312) It is possible now to show an SFSafariViewController with entersReaderIfAvailable set to false. * Refactors WebpageOperation to subclass ComposedOperation (#315) * Extended WebpageOperation with the ability to configure entersReaderIfAvailable at initialization. It is possible now to show an SFSafariViewController with entersReaderIfAvailable set to false. * Fixed a bug in WebpageOperation that that resulted in a retain cycle. * - Refactored WebpageOperation as ComposedOperation to fix a retain cycle. - Added Documentation. * Fixed some typos in WebpageOperationTests. * Implemented OpenInSafariOperation (#317) * Implemented OpenInSafariOperation * Made the displayControllerFrom non optional. * Refactored OpenInSafariOperation. * Fixes a bug removing dependencies on Condition (#309) The issue is that ComposedCondition must remove the dependency on its composed condition too. * Improves cancellation checks in main() (#319) * [OPR-287]: Invokes observers in main main() is called from start, and we already check that the operation is not cancelled. Therefore the check at the start of main is redundant. However, we don't check after the observers have been executed that the operation is cancelled. * [OPR-287]: SwiftLint fixes. * Exposes LogSeverity enum to Objective-C (#324) * Remove Reachability from CloudKitOperation (#327) * Ignore DS_Store * Rip out reachability from CloudKitOperation * [OPR-327]: Adds trailing closure syntax * [OPR-327]: Adds TimeoutObserver * [OPR-327]: Adds tests for timeout observer * Override NSOperationQueue's mainQueue() (#330) * Override NSOperationQueue's mainQueue() to return the main queue as an OperationQueue * set maxConcurrentOperationCount to 1 * Adds missing functionality of UIAlertController to AlertOperation (#334) * Added missing functionality of UIAlertController to AlertOperation. * Annotated new functionality as public. * Added test cases for new functionality. * Made alert property of AlertOperation private. * SwiftLint corrections. * Added a test for preferredAction and fixed a but related to it. * Made UserIntent enum objc accessbile (#341) * Fixed network observer flickering (#338) Added tests for multiple operations having network observer * Supports error recovery in GroupOperation (#326) * [OPR-326]: Adds Errors subtype in Operation * [OPR-326]: Refactors GroupOperation willFinish API * Revert "[OPR-326]: Adds Errors subtype in Operation" This reverts commit 759f2ef3643cafbbda3544185234b8adeec474ef. * [OPR-326]: WIP on group operation errors * [OPR-326]: Fixes issues with retry operation tests This is still not quite right. * [OPR-326]: Allows RetryOperation to fully recover from errors * [OPR-326]: Fixes issue with tests * [OPR-326]: Tweaks ProfilerTest case * [OPR-326]: Refactors ComposedOperation to just subclass GroupOperation * [OPR-326]: Changes behaviour when a group produces an operation * [OPR-326]: Logs when a GroupOperation successfully recovers from errors * [OPR-326]: Logs when the next operation will be added * [OPR-326]: Adds an immediate WaitStrategy * [OPR-326]: Adds the operation to the log when attempting recovery * [OPR-326]: Removes unneeded handling of child errors * [OPR-326]: Allows the WaitStrategy to be defined at init * [OPR-326]: Changes to support ComposedOperation * [OPR-326]: Speeds up CloudKit tests with .Immediate wait strategy * [OPR-326]: WIP on GroupOperation errors * [OPR-326]: Fixes a bug where operation would not retry In the case where there is a default handler, but no custom one set for the same error. * [OPR-326]: Renames internal methods to be more Swifty * [OPR-326]: Fixes errors - whoops. * Always create CLLocationManager on the main queue (#321) * [OPR-321]: Creates CLLocationManager on the main thread Also makes it thread safe. * [OPR-321]: Refactors capability to use guard & early exit. * [OPR-321]: Creates CLLocationManager lazily on the main thread Refactors UserLocationOperation to not use generic at the same time * [OPR-321]: Fixes deadlock in creating CLLocationManager * [OPR-321]: Refactors location operations for early exit * [OPR-321]: Removes use of NSThread to check for main queue * [OPR-321]: Fixes a mistake with the merge * RepeatedOperation allows for configuration block to be reset by the payload (#348) * [OPR-332]: Adds support for RetryOperation to provide a configuration block * [OPR-332]: Removes commented out code * [OPR-332]: Adds test to check that configure block is replaced * Turns on Whole Module Optimization (#350) Fixes #349 * Exposes the UIAlert for customization. (#351) This also fixes a bug where it wasn't possible to set a barButtonItem on an ActionSheet while presenting as a popover. * Fixes OperationQueue.delegate crash (SR-192) (#353) * Add failing test test__SR_192_OperationQueue_delegate_weak_var_thread_safety: Tests race condition (and crash) involving OperationQueue’s weak delegate var. * Fix for OperationQueue.delegate crash (SR-192) The underlying error is in Swift < 3.0, with concurrent reads of weak properties. See: https://bugs.swift.org/browse/SR-192 This change wraps the public delegate property with an NSLock. It also sets it to nil first-thing in deinit to safely get rid of it. * Simplistic support for CKLimitExceeded error handling (#294) * [OPR-294]: Initial work adding built in support for CKLimitExceeded * [OPR-294]: Rewrite with support for nil response * [OPR-294]: Adds support for adding error handlers in bulk * [OPR-294]: Fixes some comments * [OPR-294]: Moves error handling to CloudKitError * [OPR-294]: Adds BatchProcessErrorType This is only needed for CKMarkNotificationsOperation * [OPR-294]: Renames error protocols * [OPR-294]: Adds support for batch processing * [OPR-294]: Adds & Refactors for tests * [OPR-294]: Minor tweaks * [OPR-294]: Further tweaks * [OPR-294]: Fixes error in bisect * [OPR-294]: Adds API to replace the configure block outright * [OPR-294]: Fixes failing tests * [OPR-294]: Refactors stress tests condition * Adds TaskOperation (#355) * [OPR-313]: Adds TaskOperation * [OPR-313]: Adds more test coverage * [OPR-313]: Adds header documentation * Vastly improves thread safety in Operations (#358) * FIX: GroupOperation.operations contains the initial operations twice after beginning to execute. Cause: `GroupOperation.execute()` calls `GroupOperation.addOperations(operations)`, which then re-adds the operations back to the operations array. Solution: Added a private **`_addOperations()`** method to `GroupOperation` with an additional flag to override this behavior - used in `GroupOperation.execute()`. `addOperations()` now calls this private implementation method. * Operation.cancel(), Operation.finish() thread-safety - `Operation.cancel()` now acquires the stateLock. - `Operation.finish()` now acquires the stateLock. - `stateLock` is now NSRecursiveLock(). - var `Operation.cancelled` is thread-safe. - var `Operation.errors` is thread-safe. - Explicitly send KVO notifications on NSOperation keyPaths at the right times, avoiding lots of unnecessary notifications. - Removed “State” KVO notifications. (Previously used to trigger NSOperation isExecuting/isFinished notifications, which are now triggered explicitly.) - Added missing operationWillFinish() call to finish(). - operationDidFinish() now happens after the state has been set to .Finished. - `Operation.cancelWithError(errors)` now asserts if it’s called while the Operation is finishing or finished. * Operation.main() thread-safety, Operation.disableAutomaticFinishing - `Operation.main()` acquires the stateLock when appropriate. - `Operation.main()` manually sends the isExecuting NSOperation KVO notifications when setting executing state. - Added ability to disable Operation’s automatic calling of finish(), with `init(disableAutomaticFinishing: Bool)`. (Defaults to existing behavior - i.e. false.) * GroupOperation improvements (finish and thread-safety) - GroupOperation should only finish() after its children have finished. - `GroupOperation._addOperations()` acquires the stateLock. - `GroupOperation._addOperations()` cancels new child operations if the GroupOperation is cancelled. * RepeatedOperation.addNextOperation() must check cancelled - RepeatedOperation.addNextOperation() now checks cancelled status. * Added new cancellation-related tests * Added new GroupOperation tests * Added Operation KVO notification tests (for NSOperation keyPaths) * Fixed spurious commit * Handle more possible cases in Operation.main() - Check that the Operation is not already executing. - Check that the Operation has not been finished by a WillExecute observer (either directly or as a side-effect of something else). Added a test case that demonstrates this possibility. * Add missing super.init() calls * More GroupOperation cancelling fixes - Changed the internal WillCancelObserver to a DidCancelObserver to ensure that the cancelled state has been set prior to cancelling child operations. (This ensures that side-effects of propagating cancellation to child operations - like RepeatedOperation attempting to add the next operation - can safely check the cancelled status.) * GroupOperation should not call queue.cancelAllOperations() Calling queue.cancelAllOperations() also cancels the finishingOperation, which skips properly waiting until all other child operations are finished. Fixed test. * Added willProduceOperation method to OperationQueueDelegate, fix GroupOperation handling of child-produced operations Informational method only. This enables GroupOperation to add child-produced operations to its internal operations array, and thus cancel them when the GroupOperation is cancelled. Added tests. * GroupOperation should ignore queue delegate calls from other queues Added missing guard at the top of the queue delegate methods in GroupOperation. Added test to illustrate simple failure case this change covers. * Refactor lock usage in Operation.finish() and .cancel() - Refactor lock usage to hold the stateLock only when necessary or manipulating internal state, and *not* when sending KVO notifications or notifying observers. - Improvements and fixes to KVO Notification Tests. * Further refactor lock usage in Operation (.execute()) - Refactor lock usage in `Operation.execute()` to hold the stateLock only when necessary or manipulating internal state, and *not* when sending KVO notifications or notifying observers. * Add a number of new StressTests that previously failed/crashed New tests have support for a `batches` parameter. * Initial fix for Logging-related crashes (thread-safety issues) - `Operation._log` must not be a lazy var. From the Swift book: > If a property marked with the lazy modifier is accessed by multiple threads simultaneously and the property has not yet been initialized, there is no guarantee that the property will be initialized only once. For more: https://bugs.swift.org/browse/SR-1042 - `Operation.log` must be thread-safe. Initial fix involves capturing a copy of the logging context (settings + operationName) at the time of access of `Operation.log`, returning that captured context as a LoggerType, and surrounding access of .log with a Read/Write lock. - LogManager properties must be thread-safe. * Refactor lock usage in GroupOperation - var `GroupOperation.operations` is now thread-safe. - GroupOperation now utilizes a private CanFinishOperation to safely transition to executing the finishingOperation. (See code & comments.) - GroupOperation now has its own lock that is used sparingly to protect finishing state. - `GroupOperation._addOperation()` now utilizes the groupFinishLock. * Minor tweaks - `Operation.stateLock` should remain private. * SwiftLint clean-up * Refactor lock usage in GroupOperation - Refactor lock usage to hold the groupFinishLock only when necessary or manipulating internal state, and *not* when sending KVO notifications, notifying observers, or changing additionalOperations state (which might send KVO notifications or notify observers). * Clean-up - Remove asserts from `Operation.cancelWithErrors()`. Operation cancellation methods should be safe to call at any time without asserting. - Other minor tweaks. * Clean-up - Moved NSOperationKeyPaths to extension NSOperation.KeyPath enum. * Clean-up * Clean-up - Remove unneeded `self.` * Clean-up * Clarify docs & re-formatting * Add new inits to Queue (NSQualityOfService and qos_class_t) Per code review. * Clean-up of GroupOperation * Make Operation.cancel() final (#359) Per discussion in: https://github.com/danthorpe/Operations/pull/293 https://github.com/danthorpe/Operations/pull/358#discussion_r70167086 * Supports composing simple types for Result injection (#362) * [OPR-362]: Linting whitespace changes * [OPR-362]: Adds support for composing “executors” inside a final Operation type This is a convenience class to aid adoption of _Operations_ without requiring types to subclass Operation. Instead, classes only need to conform to Executor, and then can use the Execute class, which support cancellation, and result injection. * Supports async executors (#363) * Fixes a finished log message (#365) The "Operation Did finish" log was using the opposite logic for error logging * Group's internal queue is non-public; exposes appropriate properties (#361) * Make GroupOperation's internal queue non-public, and expose appropriate properties on GroupOperation - Make GroupOperation.queue ~private~internal. (So it can be tested.) - Expose appropriate run-time editable properties of the GroupOperation’s queue as properties on GroupOperation. Specifically: - public var maxConcurrentOperationCount: Int - public var suspended: Bool - public var qualityOfService: NSQualityOfService - Add tests. * [OPR-361]: Support underlying queue in Group * GatedOperation cancels composed operation when gate is closed (#377) * [OPR-377]: Adds early exit with guard * [OPR-377]: Refactors GatedOperation execute * [OPR-377]: Fixes typo * Result Injection protocol improvements (#378) * [OPR-378]: Updates result injection APIs * [OPR-378]: Adds unit tests * [OPR-378]: Removes unnecessary weak self capture * Fixes dependency gets added twice if it's direct & indirect (#379) * [OPR-379]: Adds a failing unit test * [OPR-379]: Makes indirect dependencies unique set * Removes TaskOperation from non-macOS platforms (#382) * Removes AlertPresentation mutual exclusion (#383) * Adds IgnoredCondition (#385) * Filters out indirect dependencies which have already been added (#386) * Fixes issues with ignored condition (#390) This means that conditions which are ignored mean that the attached operation does not execute, but also does not finish with an error. It’s a nicer use case than GatedOperation. This works by checking the OperationResult for .Ignored and then only cancel() instead of cancelWithError(). Note that if the operation also has .Failed(errors) condition result, in addition to .Ignored then the operation will still not run but this time with errors (as expected). Note that if the operation also has .Satisfied condition result, in addition to .Ignored then the operation will not run, but without errors. * NoFailedDependenciesCondition supports ignoring cancelled operations (#397) Fixes #396. * [OPR-396]: NoFailedDependenciesCondition support ignoring cancels * [OPR-396]: Refactors initializer * [OPR-396]: Renames the condition * Ability to add configuration to the next (retried) CloudKitOperation (#395) * Adds CloudKitOperation.setPrepareForRetryHandler() * Adds BatchedCloudKitOperation.setPrepareForNextOperationHandler() * Clean-up * Updated new APIs, added documentation -Simpler, cleaner, better APIs. -Added documentation and examples for the new APIs. * Add documentation for BatchedCloudKitOperation. * Updates project header (#399) * [OPR-399]: Updates the header * [OPR-399]: Updates the README to point to the new URL for header * Updates guidelines (#400) * [OPR-400]: Updates copyright holders to “ProcedureKit” * [OPR-400]: Adds a code of conduct * [OPR-400]: Fixes a markdown formatting issue * [OPR-400]: Adds CONTRIBUTING guidelines * [OPR-400]: Moves CONTRIBUTING to .github directory * [OPR-400]: Removes an empty section * [OPR-400]: Adds instruction on adding verbose logs. * [OPR-400]: Updates CONTRIBUTING guideline * [OPR-400]: Updates README too * [OPR-400]: Fixes some typos * Creates ProcedureKit project (#401) * [OPR-401]: Sets up ProcedureKit project * [OPR-401]: Adds ProcedureKitMobile This will cover iOS & watchOS * [OPR-401]: Adds ProcedureKitTV * [OPR-401]: Fixes Runtime Search Paths * [OPR-401]: Adds StressTests * [OPR-401]: Adds ProcedureKitMac * [OPR-401]: Enables code coverage on all testable schemes * [OPR-401]: Adds ProcedureKitCloud * [OPR-401]: Changes to module imports * [OPR-401]: Changes Cloud to latest deployment versions * ProcedureKit CI - Stage 1 (#403) * [OPR-403]: Changes Stress Tests to only run as part of the ProcedureKitMac scheme * [OPR-403]: Changes Cloud minimum target versions * [OPR-403]: Adds tests to CI - ProcedureKit macOS * [OPR-403]: Fixes Operations mac tests * [OPR-403]: Fixes Operations tests 2 * [OPR-403]: Fixes Swift version to 2.2 * [OPR-403]: Moves common scripts around * [OPR-403]: Updates scripts * [OPR-403]: Changes to the Fastlane name for mac * [OPR-403]: Updates build dependencies * [OPR-403]: Sets the correct destination platform * [OPR-403]: Updates scan invocation * [OPR-403]: Updates Fastfile * [OPR-403]: Trying to use which to find bundle * [OPR-403]: Using quotes * [OPR-403]: Adds setup first * [OPR-403]: Putting the whole setup into quotes * [OPR-403]: Attempting to add multiple lines to the command * [OPR-403]: Puts it all on one line * [OPR-403]: Adds more ProcedureKit steps * [OPR-403]: Fixes error in Stress Tests build settings * [OPR-403]: Pipline Uploads * [OPR-403]: Fixes pipelines * [OPR-403]: Uses pipeline upload correctly * [OPR-403]: Fixes error in mobile tests * [OPR-403]: Adds watchOS * [OPR-403]: Removes automatic code signing * [OPR-403]: Comments out watchOS builds * [OPR-403]: Adds TV * [OPR-403]: Removes ad-hoc code signing * [OPR-403]: Fixes Operations iOS * [OPR-403]: Sets iPhone Developer automatic code signing * [OPR-403]: Updates buildkite agent tags for iOS Simulator * [OPR-403]: Sets the development team in xcargs * [OPR-403]: Enables automatic code signing without a team set * [OPR-403]: Fixes issues with code signing settings for TV * [OPR-403]: Removes the development team * [OPR-403]: Puts everything into a single pipeline * [OPR-403]: Cleans up the pipeline * [OPR-403]: Sets personal team for mobile unit tests * [OPR-403]: Updates the Fastlane lane names * [OPR-403]: Adds a copy frameworks build phase * [OPR-403]: Removes copy files phase * [OPR-403]: Comments out problematic build jobs * [OPR-403]: Removes Operations CI jobs * ProcedureKit CI - Stage 2 (#404) * Update CI dependencies (#409) * [OPR-409]: Updates dependencies and enables pipeline * [OPR-409]: Fixes YML * [OPR-409]: Fully specifies the destination Starting to really not like Fastlane * [OPR-409]: Switches to iOS 10 simulators. * [OR-409]: Sets the developer directory * [OPR-409]: Removes tvOS for Mobile framework * [OPR-409]: Reorders the jobs * Add base types to ProcedureKit (#405) * [OPR-405]: Creates Procedure * [OPR-405]: Sets the Swift version * [OPR-405]: Cleans project * [OPR-405]: Changes to destination * [OPR-405]: Stops using Fastlane for testing macOS * [OPR-405]: Adds initial files for ProcedureQueue * [OPR-405]: Defines ProcedureObserver * [OPR-405]: Adds the default implementation of ProcedureObserver * [OPR-405]: Adds the rest of the observer protocols * [OPR-405]: Adds @available annotations * [OPR-405]: Adds block based observers * [OPR-405]: Adds Protector / DispatchQueue extension * [OPR-405]: Further updates to observers API * [OPR-405]: Adds extension to Operation This is for addCompletionBlock - but will be used for more stuff when we get into dependencies * [OPR-405]: Fixes lint issues * [OPR-405]: Adds Procedure protocol with AbstractProcedure * [OPR-405]: Starts interfaces in AbstractProcedure for execute & finish * [OPR-405]: Adds state transition * [OPR-405]: Refactors Procedure to be protocol based. * [OPR-405]: Adds most of the cancellaton functionality * [OPR-405]: Adds main implementation With a few TODOs * [OPR-405]: Fixes available renames * [OPR-405]: Changes AbstractProcedure back to Procedure * [OPR-405]: Adds Testing framework With TestProcedure class * [OPR-405]: Adds basic API to ProcedureTestCase * [OPR-405]: Updates dependencies * [OPR-405]: Commenting out non mac unit tests Run CI on iOS Simulators is basically impossible on beta version of Xcode. * [OPR-405]: Adds finishing and cancellation tests * [OPR-405]: Adds some finishing tests * Adds Logging (#428) * [OPR-428]: Adds LogSeverity * [OPR-428]: Adds logger * [OPR-428]: Updates logging stuff * [OPR-428]: Adds logging tests * Group (#430) * [OPR-430]: Adds Group * [OPR-430]: Adds initializers to Group * [OPR-430]: Adds add child API to Group * [OPR-430]: Corrects spelling * [OPR-430]: Adds finishing APIs to Group * [OPR-430]: Adds extension of unavailable APIs * [OPR-430]: Adds GroupObserverProtocol * [OPR-430]: Adds error handling and recovery to Group * [OPR-430]: Improves group observers API * [OPR-430]: Adds first group test * [OPR-430]: Adds some basic tests for Group * [OPR-430]: Adds more unit test for Group * [OPR-430]: More tests for group * Adds User Intent (#439) * [OPR-439]: Adds UserIntent to Procedure * [OPR-439]: Adds userIntent to Group * Stress Tests Phase 1 (#442) * [OPR-442]: Adds StressTestCase and completion block stress tests * [OPR-442]: Uses StressLevel directly. * [OPR-442]: Refactors the test case names * [OPR-442]: Refactors to remove StressTestCase Instead the stress function can be added to the base ProcedureKitTestCase * [OPR-442]: Adds group cancel stress test * [OPR-422]: Refactors group stress tests These are currently failing * [OPR-422]: Refactors schemes, as stress tests are run as part of Mac tests * [OPR-442]: Updates Stress Tests batches Uses intermediate BatchProtocol, and exposes a measure API. * [OPR-422]: Changes the active developer directory * [OPR-422]: Adds group child finishing order stress test * [OPR-422]: Fixes incorrect pipeline step * [OPR-422]: Adds more stress tests for Procedure * [OPR-422]: Fixes TestError mistake * [OPR-422]: Changes to use didCancelBlockObserver Instead of didFinishBlockObserver - there might be a subtle bug here. * [OPR-422]: Disables some checks - have identified that there is definitely an error in finishing logic * [OPR-422]: Moves stress tests to their own scheme * [OPR-422]: Adds stress fastlane * [OPR-422]: Trying to see how to trigger stress tests * [OPR-422]: Removing - * [OPR-422]: Changes the trigger to ProcedureKit * [OPR-422]: Add the pipeline update step back * [OPR-422]: Fixes yml * [OPR-422]: More changes to pipeline template * [OPR-422]: Fixes the slug This is case sensitive! * [OPR-422]: Triggers a different pipeline stress tests * [OPR-422]: Adds commit message to stress test build * [OPR-422]: Modifies measure to be a little quicker * [OPR-422]: Updates baselines with Mac Pro * [OPR-422]: Fixes mistake with finishing from cancel * Fix issue with newlines in pipeline upload (#445) * [OPR-445]: Removes message from upload script * [OPR-422]: Puts the commit back * Initial work on Result Injection (#446) * Adds Dependencies & Conditions (#429) * [OPR-429]: Adds Condition protocol and class * [OPR-429]: Adds conditions to procedure and queue * [OPR-429]: Adds tests for Conditions Also adds XCTAssertProcedure functions to make verifying Procedure behaviour more consistent. * [OPR-429]: Adds remaining unit tests for conditions Still got Ignored Condition to add * [OPR-429]: Fixes some documentation * [OPR-429]: Performs the stress tests in the same build * [OPR-422]: Adds stress tests for conditions * [OPR-429]: Adds IgnoredCondition * ProcedureKitError (#437) * [OPR-437]: Regorganized the Core group * [OPR-437]: Refactors Errors into ProcedureKitError * Completes Result Injection API test coverage (#447) * [OPR-447]: Sorts out ResultInjection * [OPR-447]: Completes result injection tests * Fixes Xcode 8 GM issues (#463) * BlockProcedure (#450) * [OPR-450]: Adds BlockProcedure * [OPR-450]: Adds unit tests for map and block procedures * [OPR-450]: Adds some stress tests for block procedure * [OPR-450]: Updates stress tests * [OPR-450]: Fixes Xcode 8 GM escaping issue * [OPR-450]: Papers over some possible issues with finishing. In many cases the `should finish after cancelling` logic is returning false. * [OPR-450]: Removes some excessive logging * [OPR-450]: Adjusts variation to 15% * Mutual exclusive conditions (#448) * [OPR-448]: Adds MutualExclusion * [OPR-448]: Adds support for adding dependencies for mutual exclusion * [OPR-448]: WIP on mutual exclusivity * [OPR-448]: Finishes off test cases for mutual exclusivity * [OPR-448]: Refactors add condition API to attach condition I want to make the API consistent - but not choose consistency over intent. So, `add(dependency: myDependency)` makes sense - as it signals that the dependency is already managed by some other queue/system. Where as for a Condition, we specifically _attach_ it to Procedure instance, and it does not (ideally should not) be managed outside the Procedure. So, I want the concept of “attaching conditions to procedures” to be the language which is used to describe the behaviour. * DelayProcedure (#449) * [OPR-449]: Adds delay procedure * [OPR-449]: Adds DelayProcedure tests * Renames Group to GroupProcedure (#468) * Adds ProcedureKit.podspec (#467) * Adds NegatedCondition (#471) * Adds SilentCondition (#472) * Procedure finishing fixes (#474) * Resolve finishing issues related to FinishingFrom. * Add StressTest that covers concurrent calls to finish() * Revert ProcedureKitTestCase expectation fulfillment back to the main queue. * Adds BlockCondition (#473) * Adds NoFailedDependenciesCondition (#470) * Adds TimeoutObserver (#475) * [OPR-475]: Adds TimeoutObserver * [OPR-475]: Fixes issues with TestProcedure It was not correctly delaying. * Procedure name and identity (#478) * [OPR-478]: Adds name and Identity * [OPR-478]: Fixes some failing tests * [OPR-478]: Fixes another failing name test * Adds BlockObserver (#480) * [OPR-480]: Adds BlockObserver * [OPR-480]: Tweaks to stress tests * Adds ComposedProcedure & GatedProcedure (#487) * RepeatProcedure (#488) * [OPR-488]: Initial work on RepeatProcedure * [OPR-488]: Adds remaining test coverage * RetryProcedure (#491) * [OPR-491]: Adds RetryProcedure * [OPR-491]: Unifies the generic init pattern for repeat and retry procedures * Adds support for Capabilities (#492) * [OPR-492]: Fixes incorrectly spelt protocol * [OPR-492]: Adds Capability Including CapabilityProtocol, GetAuthorizationStatus, Authorize, AuthorizedFor * Adds BackgroundObserver (#476) * [OPR-476]: Fixes stress tests * [OPR-476]: Adds BackgroundObserver * [OPR-476]: Gets the Mobile test suite working * [OPR-476]: Switches code coverage on * [OPR-476]: Adds missing callback This was causing a failing unit test * [OPR-476]: Removes unnecessary build phase * [OPR-476]: Finishes BackgroundObserver tests * [OPR-476]: Removes verbose logging in test case * Adds FilterProcedure (#496) * [OPR-496]: Adds FilterProcedure * [OPR-496]: Adds filter method for when Result is a sequence * Adds ReduceProcedure (#497) * [OPR-497]: Adds ReduceProcedure * [OPR-497]: Refactors Map, Filter adds FlatMap MapProcedure is really a TransformProcedure. MapProcedure and FilterProcedure are now simple subclasses of ReduceProcedure, along with FlatMapProcedure. * Adds NetworkObserver (#498) * [OPR-498]: Adds NetworkObserver Additionally, this updated ProcedureKitTestCase to automatically add async expectation fulfills around operations which might be produced by a procedure. * [OPR-498]: Refactors ProcedureKitTestCase slightly for Swift 3 conventions. * Adds Location.Capability (#499) * [OPR-499]: Adds ProcedureKitLocation framework * [OPR-499]: Supports sychronous dispatch onto the main queue This is safe to call if already on the main queue. * [OPR-499]: Adds Capability.Location * Adds UserLocationProcedure (#500) * [OPR-500]: Adds UserLocationProcedure * [OPR-500]: Removes unneeded error struct * [OPR-500]: Fixes issue with tvOS * Corrects minimum deployment targets (#503) Fixes #501 * [OPR-501]: Fixes issues with deployment versions * [OPR-501]: Setting tvOS to 9.2 * Adds ReverseGeocodeProcedure (#502) * [OPR-502]: Adds ReverseGeocodeProcedure * [OPR-502]: Adds ProcedureKitMobile as a build dependency * [OPR-502]: Fixes a mistake where macOS location tests were requiring iOS simulator * [OPR-502]: Uses gym to ensure iOS builds ProcedureKitMobile before testing Location * [OPR-502]: Use scan instead of gym This is a hack. I want to make sure that when we test ProcedureKitLocation on iOS we have build ProcedureKitMobile. * Adds ReverseGeocodeUserLocationProcedure (#504) * [OPR-504]: Adds/renames files * [OPR-504]: Adds ReverseGeocodeUserLocationProcedure * [OPR-504]: Rounds out the unit tests on ReverseGeocodeUserLocationProcedure * Makes procedures open where appropriate (#510) * Refactors BlockProcedure (#511) * Adds AnyProcedure (#516) * [OPR-516]: Removes import foundation This is done by the prefix header * [OPR-516]: Adds AnyProcedure * [OPR-516]: Uses the correct underlying queue throughout AnyProcedure * Fixes regression of failing release build (#518) * Renames AuthorizationStatusProtocol to AuthorizationStatus (#519) * Renames capability reated procedures (#520) * Renames attach(condition: Condition) to add (#521) * Adds Capability.CloudKit (#523) * [OPR-523]: Adds Capability.CloudKit * [OPR-523]: Enables CI builds for CloudKit stuff on iOS and tvOS * Adds ProcedureKitNetwork framework (#524) * [OPR-524]: Adds ProcedureKitNetwork framework * [OPR-524]: Adds Network to CI jobs * [OPR-524]: Renames Stress Tests job * [OPR-524]: Shares the network scheme * [OPR-524]: Imports Foundation instead of Cocoa * [OPR-524]: Forces Stress Tests onto a non-simulator agent * Adds NetworkDataProcedure (#525) * [OPR-525]: Adds NetworkDataProcedure * [OPR-525]: Fixes up some unit tests * [OPR-525]: Adds missing test coverage * Moves TestableNetwork into TestingProcedureKit framework (#526) * Refactors injectDependency API to be an extension on ProcedureProtocol instead. (#527) * Adds transform block result injection API (#528) * [OPR-528]: Refactors result injection Uses an intermediatory injectResult(from: via:) API, which allows the caller to provide a throwing block to transform the result into the requirement. * [OPR-528]: Removes unneeded return * [OPR-528]: Fixes error in ProcedureKitLocation * Adds default empty implementations some queue delegate methods (#531) Only added the will-do-something ones. Fixes #530 * Adds space in the repo for presentations (#533) * [OPR-533]: Adds CocoaHeads Stockholm talk Contact @danthorpe if you want the original Keynote file. * [OPR-533]: Adds Sky-UK iOS Community Talk * [OPR-533]: Adds a presentations README * Disables the log for AnyProcedure (#534) * Fixes bug where GroupProcedure collects errors from children after its been cancelled (#532) * [OPR-532]: Adds failing test * [OPR-532]: Checks cancelled state of the group We can exit this delegate callback early if the group has already been cancelled. * [OPR-532]: Removes default implementation of willFinish It seems that adding default implementations here causes some odd behaviour / intermittent crash where this is overwritten in the QueueDelegate. * [OPR-532]: Fixes a unit test which is now mis-counting errors. * Adds .then { } API (#536) * [OPR-176]: Adds then extension on Operation * [OPR-176]: Implements .then { } API * [OPR-176]: Adds enqueue method to a collection of Operations * [OPR-176]: Fixes header docs * Removes default argument for session in NetworkDataProcedure (#538) * Tweaks the cancel block procedure stress tests (#539) There might be an underlying issue. As normally a batch of 10_000 finishing in ~ 5 seconds. But sometimes fails because it times out, meaning that an expectation is not getting fulfilled. * Moves ProcedureKit imports to umbrella headers (#540) * [OPR-540]: Putting the appropriate imports into umbrella headers * [OPR-540]: Fixing issues with importing ProcedureKit into TestingProcedureKit * Updates ProcedureKit podspec with subspecs (#508) * [OPR-508]: Lints podspec without an warnings or errors. * [OPR-508]: Fixes errors running tests * Adds ResilientNetworkProcedure (#537) * [OPR-537] Adds ResilientNetworkProcedure * [OPR-537]: Updates retry request with error code * [OPR-537]: Adds edge case for ResilientNetworkProcedure In some situations, the HTTP status code might well require (depending on the behaviour) a retry. * [OPR-537]: Fixes simple unit tests * Refactor ResultInjection to use PendingValue enum (#541) * [OPR-541]: Refactors ResultInjectionProtocol to use PendingValue enum * [OPR-541]: Renames ResultInjectionProtocol to ResultInjection * Fixes BlockProcedure stress tests (#544) * [OPR-544]: Fix test__cancel_block_procedure() failures It was possible for the testing BlockProcedure to finish prior to the `block.cancel()` call, which would result in some of the BlockProcedures never cancelling (as they had finished first), and a failing test. Fixed by using a semaphore inside the BlockProcedure’s block. Additionally, the test now waits for all BlockProcedures to cancel *and* finish. * [OPR-544]: Added a new stress test for BlockProcedure cancelling & finishing behavior (allowing for possible races between cancelling and finishing) * Fixes ExclusivityManager synchronization bug (#545) Fixes #543 The ExclusivityManager was using `DispatchQueue.initiated`, which returns a global **concurrent** queue, however its internals are dependent upon **serial** execution of add/remove. Modified to use a serial queue. * Adds ResultProcedure and overloads injectResult(from:) (#546) * Adds HTTPResult<Payload> (#547) * Fix test crashes caused by QueueTestDelegate (#549) QueueTestDelegate was not thread-safe. This could result in crashes running random tests. Fixed by making QueueTestDelegate’s methods thread-safe. * Adds ProcedureKitTestCase wait function that takes an array (#552) * Adds TestingProcedureKit podspec (#553) * Adds Mutual Exclusivity concurrency testing (#550) * Add ConcurrencyTestCase Exposes functionality to test operation concurrency. * Add Mutual Exclusivity concurrency tests * Refactored ConcurrencyTestCase * Refactored ConcurrencyTestCase * Adds didExecuteObserver (#554) * [OPR-554]: Adds code with failing test * [OPR-554]: Calls didExecuteObservers * [OPR-554]: Fixes a typo * [OPR-554]: Adds some documentation to the DidExecuteObserver * Fixes mistake in Fastfile (#557) * [OPR-557]: Fixes error in Fastfile * [OPR-557]: Removes duplicate scan I remember now, as part of location, we used to build Mobile too - because there was a dependency on iOS. But this has since been removed. * Fixes release configuration issues with Xcode 8.1 (#559) Fixes #548 * [OPR-548]: Fixes issue with Xcode 8.1 release configuration * [OPR-548]: Fixes some SwiftLint warnings. * [OPR-548]: Fixes Xcode project warnings in Xcode 8.1 * Adds GroupProcedure concurrency tests (#556) * Add GroupConcurrencyTestCase * Add GroupProcedure.maxConcurrentOperationCount tests * Fixes registrar typo (#562) * Adds NetworkDownloadProcedure. (#565) The implementation for class and test is largely inspired by `NetworkDataProcedure` class. * Adds NetworkUploadProcedure. (#567) * Add NetworkUploadProcedure. The implementation class and test has been largely inspired by `NetworkDataProcedure`. The requirement type is currently a pending value of a tuple. Maybe would it make more sense to create a dedicated struct to add more clarity in the case of dependencies injection ? * Use an `HTTPRequirement` struct for requirement. As discussed, an `HTTPRequirement` struct is used instead of a tuple. * Fixes Condition to support ResultInjection (#566) * [OPR-566]: Replaces Condition result with PendingValue<ConditionResult> * [OPR-566]: Refactors how conditions are evaluated This fixes a existing issue where the ConditionEvaluation enum was basically just like ConditonResult, except that it could hold an array of errors. This has been resolved by using an internal error type `ProcedureKitError.FailedConditions` to collect multiple errors from failed conditons, so that we can reduce a sequence of `ConditionResult`s into a single one. * [OPR-566]: Explicitly adds a Result typealias * [OPR-566]: Fixes error where cancelled conditions would throw a fatal error. * [OPR-566]: Removes verbose log * Adds ProcessProcedure. (#570) * Add ProcessProcedure. The class has been largely inspired by the original `TaskOperation`. Refers to #568. * Apply requested changes. Correctly implement `Equatable` for sub-error enum. Use camel case for the enum. Fix closure self semantics. * Calls TestableReverseGeocoder completionHandler on the main queue (#572) * Improves performance of adding observers * Procedure.add(observer:) performance tweak Append directly to the protected observers array. * Fix swiftlint `variable_name` warning * Makes ProcedureQueue.add(operation: Operation) method open (#578) * Fixes NetworkObserver thread-safety (#576) (#577) * Fix NetworkObserver thread-safety By fixing NetworkActivityController `start()`/`stop()` thread-safety. (And making private methods/variables private.) * NetworkObserver test fixes * Reduce test delay * Additional GroupProcedure tests (#579) * Adds CloudKitProcedure (#542) * [OPR-542]: Adds shell of CloudKit files * [OPR-542]: Adds extensions for CKOperation * [OPR-542]: Adds extensions for CKDatabaseOperation * [OPR-542]: Adds extensions for CKAcceptSharesOperation * [OPR-542]: Adds extensions for CKDiscoverAllContactsOperation * [OPR-542]: Adds extensions for CKDiscoverAllUserIdentifiesOperation * [OPR-542]: Adds extensions for CKDiscoverUserIdentitiesOperation * [OPR-542]: Adds extensions for CKDiscoverUserInfosOperation * [OPR-542]: Adds extensions for CKFetchDatabaseChanges * [OPR-542]: Adds extensions for CKFetchDatabaseChangesOperation * [OPR-542]: Adds extensions for CKFetchRecordChangesOperation * [OPR-542]: Moves the interface into the extension files * [OPR-542]: Fixes dispatchQueue * [OPR-542]: Adds extensions to CKFetchRecordsOperation * [OPR-542]: Adds extensions for CKFetchRecordZoneChangesOperation * [OPR-542]: Removes unnecessary public properties * [OPR-542]: Adds extensions for CKFetchRecordZonesOperation * [OPR-542]: Adds extensions for CKFetchShareMetadataOperation * [OPR-542]: Adds extensions for CKFetchShareParticipantsOperation * [OPR-542]: Adds extensions for CKFetchSubscriptionsOperation * [OPR-542]: Adds extensions for CKMarkNotificationsReadOperation * [OPR-542]: Adds extensions for CKModifyBadgeOperation * [OPR-542]: Adds extensions for CKModifyRecordsOperation * [OPR-542]: Adds extensions for CKModifyRecordZonesOperation * [OPR-542]: Adds extensions for CKModifySubscriptionsOperation * [OPR-542]: Adds extensions for CKQueryOperation * [OPR-542]: Adds missing APIs for error handlers * [OPR-542]: Adds testable CK operation classes * [OPR-542]: Adds tests for CKOperation, CKDatabaseOperation and CKAcceptSharesOperation * [OPR-542]: Removes missing test cases from tvOS * Small typo fix * Adds tests for CKDiscoverAllContactsOperation * Adds tests for CKDiscoverAllUserIdentitiesOperation * Adds tests for CKDiscoverUserIdentitiesOperation * Adds tests for CKDiscoverUserInfosOperation * [OPR-542]: Adds tests for CKFetchAllChanges protocol * [OPR-542]: Adds tests for CKFetchDatabaseChangesOperation * [OPR-542]: Adds tests for CKFetchNotificationChangesOperation * [OPR-542]: Adds tests for CKFetchRecordChangesOperation * [OPR-542]: Adds tests for CKFetchRecordsOperation * [OPR-542]: Added missing `recordZoneFetchCompletionBlock` for CKFetchRecordZoneChangesOperationProtocol extensions * [OPR-542]: Adds tests for CKFetchRecordZoneChangesOperation * [OPR-542]: Adds tests for CKFetchRecordZonesOperation * [OPR-542]: Adds tests for CKFetchShareMetadataOperation * [OPR-542]: Adds tests for CKFetchShareParticipantsOperation * [OPR-542]: Adds tests for CKFetchSubscriptionsOperation * [OPR-542]: Minor typo fix To follow the original API naming, change `setMarkNotificationReadCompletionBlock` to `setMarkNotificationsReadCompletionBlock`. * [OPR-542]: Adds tests for CKMarkNotificationsReadOperation * [OPR-542]: Adds tests for CKModifyBadgeOperation * [OPR-542]: Adds tests for CKModifyRecordsOperation * [OPR-542]: Adds tests for CKModifyRecordZonesOperation * [OPR-542]: Adds tests for CKModifySubscriptionsOperation * [OPR-542]: Adds tests for CKQueryOperation * [OPR-542]: Fixes whitespace in test cases * [OPR-542]: Adds CloudKitProcedure<CKAcceptSharesOperation> tests * [OPR-542]: Fixes tests on tvOS. Again. * [OPR-542]: Adds tests for CKDiscoverAllContactsOperation * [OPR-542]: Adds tests for CKDiscoverAllUserIdentitiesOperation * [OPR-542]: Adds tests for CKDiscoverUserIdentitiesOperation * [OPR-542]: Adds tests for CKDiscoverUserInfosOperations * [OPR-542]: Adds tests for CKFetchDatabaseChangesOperation * [OPR-542]: Unifies testing of common properites * [OPR-542]: Adds tests for CKFetchNotificationChangesOperation * [OPR-542]: Adds tests for CKFetchRecordChangesOperation * [OPR-542]: Adds test for CKFetchRecordsOperation * [OPR-542]: Adds tests for CKFetchRecordZoneChangesOperation * [OPR-542]: Adds test for CKFetchRecordZonesOperation * [OPR-542]: Adds tests for CKFetchShareMetadataOperation * [OPR-542]: Adds tests for CKFetchShareParticipantsOperation * [OPR-542]: Fixes inconsistently named tests * [OPR-542]: Adds tests for CKFetchSubscriptionsOperation * [OPR-542]: Adds tests for CKMarkNotificationsReadOperation * [OPR-542]: Adds tests for CKModifyBadgeOperation * [OPR-542]: Adds tests for CKModifyRecordsOperation * [OPR-542]: Adds tests for CKModifyRecordZonesOperation * [OPR-542]: Adds test for CKModifySubscriptionsOperation * [OPR-542]: Adds test for CKQueryOperation * [OPR-542]: Adds tests which trigger default retry behavior * [OPR-542]: Adds tests for set/get all errors handlers * [OPR-542]: Adds tests for custom error handlers * Adds Profiler (#573) * Implement Profiler as specified in #569. The implmentation is largely inspired by the original `Profiler.swift` file. * Add first set of tests. The test has been largely inspired by the original tests classes. I have a commented test taht fails. After trying to debug for a while, I suspect maybe an issue inside GroupProcedure or the original implementation. * Apply requested changes. Perform changes as requested. * Adds public initialiser to HTTPRequirement (#586) Declaring a constructor for the `HTTPRequirement` allows the construction of the struct without any issue. * Removes GroupProcedureObserver protocol (#583) Instead ProcedureObserver takes over this responsibility. * [OPR-574]: Cleans up white space & style for consistency * [OPR-574]: Uncomments failing test * [OPR-574]: Adds new API to ProcedureObserver protocol * [OPR-574]: Removes temporary print statements * [OPR-574]: Refactors to support willAdd & didAdd observer callbacks. * [OPR-574]: Removes commented out line. * [OPR-574]: Removes group observers. * [OPR-574]: Removes extraneous logging in some tests * [OPR-574]: Makes add(observer:) open for overriding * [OPR-574]: Adds some documentation comments to public interfaces * Supports Arbitrary mutual exclusion category names (#587) Fixes #580. * [OPR-580]: Supports arbitrary mutual exclusion category names * [OPR-580]: Fixes default category for AuthorizedFor * Adds NetworkReachableProcedure (#563) * [OPR-563]: Adds Reachability functionality * [OPR-563]: Adds additional files for testing support * [OPR-563]: Adds tests for Reachability * [OPR-563]: Adds basis of NetworkReachableProcedure * [OPR-563]: Adds simple network reachability procedure tests * [OPR-563]: Fixes issue with Protector write being synchronous. * [OPR-563]: Refactors DeviceReachability slightly * [OPR-563]: Changes Protector behavior back to be non-blocking * [OPR-563]: Fixes Reachability.Device * [OPR-563]: Adds NetworkProcedure and ProcedureKitNetworkError * [OPR-563]: Fixes for network error tests * [OPR-563]: Adds remaining tests for Reachable procedure * [OPR-563]: Removes unnecessary logging * Refactors produce API (#588) * Add failing test * Test tweaks * Changes to Procedure.produce(operation:) handling Fixes failing test case, and simplifies execution flow. Changes `willEnqueue()` to `willEnqueue(on: ProcedureQueue)`. `func produce(operation: Operation)` now throws. * Ported additional test case from Operations 3.x. * swiftlint tweak * Fixed mobile tests. * Adds missing equality cases for ProcedureKitError.Context (#591) Fixes #589 * Supports merging collections of ResultInjection Procedures (#593) * [OPR-593]: Adds gather and reduce APIs * [OPR-593]: Removes the rethrows While the nextPartialResult closure can throw, this error is not re-thrown. Instead, because this block is executed after the receiver’s procedures have all finished, the error means that the `ResultProcedure` will finish with an error. * [OPR-593]: Adds test case for throwing closure * [OPR-593]: Refactors gather() so that it is a specialization of new flatMap API * Improves how stress tests are run in CI (#594) * [OPR-594]: Updates pipeline queues * [OPR-594]: Fixes yaml * [OPR-594]: Disables Thread Sanitizer for Stress Tests * [OPR-594]: Uses Release configuration for stress tests * Fix StressTestCase Batch counters thread-safety (#555) (#596) * Fixes public access levels for CKProcedure (#599) * Fixes some RepeatProcedure thread-safety issues (#597) Fix issues identified by an audit and Thread Sanitizer * Fixes Procedure & Support thread-safety (#598) * Change Protector.write() to be synchronous (and optionally return a value from the block) Thread Sanitizer identified a data race caused by the combination of the prior asynchronous `write()` and deinitialization. * Explicitly `import Dispatch` in Support.swift Fixes an occasional Xcode warning display glitch. * Fix Protector.read() to no longer require an `escaping` block * Adds back `Protector.write(_:completion:)` Although, like the new write(_:) method, this is now synchronous. * Wrap all properties of Procedure in a Protector to ensure thread-safety `errors`, `observers`, `directDependencies`, `conditions` (and associated methods) are now thread-safe * Fix comment formatting * Removes @testable import (#600) Exposes NSLock and NSRecursiveLock extensions * Add RepeatProcedure cancellation stress test (#602) * Adds more GroupProcedure test coverage (#603) * Additional / improved GroupProcedure test cases * Remove unused private setter * Refactors of Result Injection APIs (#601) * [OPR-601]: Renamed PendingResult to PendingProfileResult * [OPR-601]: Adds protocols for Input & Output * [OPR-601]: Refactors for InputProcedure & OutputProcedure * [OPR-601]: Refactors ReduceProcedure as a TransformProcedure subclass * [OPR-601]: Refactoring for InputProcedure & OutputProcedure * [OPR-601]: Refactoring Condition to use Result<Bool> * [OPR-601]: Refactors ProcedureKitNetwork result injection * [OPR-601]: Refactors Location for result injection * [OPR-601]: Removes ResultInjection.swift * [OPR-601]: Removes left over properties * [OPR-601]: Tidies up ResultProcedure & TransformProcedure * [OPR-601]: Adds finish(withResult:) API * [OPR-601]: Refactors to use finish(withResult:) * [OPR-601]: Renames HTTPRequirement & HTTPResult * Renames Result to ProcedureResult (#605) * [OPR-605]: Renames Result to ProcedureResult Just to help with any interop issues with antitypical/Result * [OPR-605]: Renames Result to ProcedureResult * Adds AsyncBlockProcedure (#606) * [OPR-606]: Adds AsyncBlockProcedure As a specialization of AsyncResultProcedure * [OPR-606]: Moves async block tests into same file * [OPR-606]: Adds AsyncTransformProcedure * Adds @escaping marker to the FinishingBlock (#607) * Fixes NetworkActivityController internal timer (#608) * NetworkActivityController's delayed hide should occur on the queue Fixes data race. * Remove outdated test * NetworkDataProcedure, NetworkDownloadProcedure, NetworkUploadProcedure thread-safety (#609) * Adds NetworkProcedure (#561) * [OPR-561]: Refactoring ResilientNetworkProcedure - Supports request timeout - Adds HTTPStatusCode where we only even consider retrying client or server errors. - Adds some initial tests * [OPR-561]: Refactors NetworkResilience * [OPR-561]: Refactor to unify reachable & resilience network procedures * [OPR-561]: Adds resilience error handling support This is so that even if the network request “succeeds” but results in say, a server error, we will still trigger retries. * [OPR-561]: Fixes typos * Add missing imports to make Xcode happier (#611) * Add explicit imports to the top of ProcedureKit files This makes Xcode happier. * Add missing imports to the top of ProcedureKitCloud files This makes Xcode happier. * Add missing imports to the top of ProcedureKitMobile files This makes Xcode happier. * Add missing imports to the top of ProcedureKitLocation files This makes Xcode happier. * Fixes BackgroundObserver data race (#614) * Makes NetworkObserver cross-platform (#613) * NetworkObserver and NetworkActivityController cross-platform work On all platforms, the following initializers are available: `NetworkObserver.init(controller: NetworkActivityController)` `NetworkActivityController.init(timerInterval: TimeInterval = 1.0, indicator: NetworkActivityIndicatorProtocol)` To implement your own network activity indicator display, conform to `NetworkActivityIndicatorProtocol`. NetworkActivityController ensures that all accesses of the indicator’s `networkActivityIndicatorVisible` property are serialized on the main queue. On iOS (but *not* in application extensions), the following convenience initializers are available that utilize `UIApplication.shared` to display/hide the network activity indicator in the status bar: `NetworkObserver.init()` `NetworkActivityController.init(timerInterval: TimeInterval = 1.0)` `NetworkActivityController.shared` * [OPR-612]: Moves NetworkObserver into Network framework * [OPR-612]: Moves NetworkObserver into ProcedureKit Keeps iOS non-extension related elements in ProcedureKitMobile * Add documentation * Fixes BackgroundObserver on iOS 8.x (#615) To support iOS < 9.0 and macOS < 10.11, NotificationCenter observers **must** be properly removed, or a crash may result. * Fixes DelayProcedure thread-safety (#616) * Fixes to Location related procedures (#619) * Capability.Location should set its registrar's delegate to nil on deinit. CLLocationManager’s delegate is `unowned(unsafe)`, and we must ensure it is set to nil before the object goes away. The only strong reference to the delegate that Capability.Location sets is stored within Capability.Location. * LocationCapabilityTests tweaks Explicitly set the test CLLocationManager’s `delegate` back to nil. Explicitly wait on `capability.requestAuthorization` to fulfill an expectation. * ReverseGeocodeProcedureTests tweaks * Fix an occasional crash running the Location tests It seems there may be an edge case in CoreLocation triggered when creating (and releasing) lots of CLLocationManager instances (as previously happened when each test, using its own TestableLocationServicesRegistrar, created a “fake” CLLocationManager). Change `TestableLocationServicesRegistrar`’s “fake” CLLocationManager (which is only used to populate a parameter in the delegate callbacks) to a static class variable. * Compiles out SystemConfiguration related stuff from watchOS (#621) * Adds an All subspec (#623) * Adds missing imports in TestingProcedureKit (#625) Noticed this issue after doing some integration testing via CocoaPods * Network*Procedure tweaks (#626) * Resolve cancellation race condition in Network*Procedure Must check `!isCancelled` inside the `stateLock`, or it is possible for a `NetworkDataProcedure`/`NetworkDownloadProcedure`/`NetworkUploadProcedur e` that is cancelled after the `execute()` function is called, but before the acquisition of the `stateLock` inside it, to continue to create a network task. * Mark `task` as `private(set)` The `task` variable should not be set outside of the `NetworkDataProcedure` / `NetworkDownloadProcedure` / `NetworkUploadProcedure`. * Memory leaks fixes highlighted by Visual Memory Debugger (#624) * TimeoutObserver should capture a weak reference to the procedure * RetryIterator should not maintain a strong reference to the RetryProcedure RetryIterator’s RetryFailureInfo (`info`) property is set right before `addNextOperation()` is called, which calls `next()` on the RetryIterator (which then uses the RetryFailureInfo). Ultimately, the RetryFailureInfo contains strong references to the RetryProcedure. And since the RetryProcedure owns the RetryIterator, which owns the RetryFailureInfo… We end up with a reference cycle. As an immediate quick fix, since the RetryFailureInfo is only used in the call to `addNextOperation()`, set it back to `.none` after the call. * Add test to catch reference cycles in RetryProcedure (Fixed by prior commit.) * GroupProcedure: ensure that internal queue is emptied on deinit Previously, a GroupProcedure that was created and released but never added to a queue would leak the child operations on its internal OperationQueue. To ensure that it is safe to release a GroupProcedure in all circumstances, add a `deinit` handler that explicitly cancels all operations on the queue, and also ensures that the queue is not suspended (so the queue will handle the clean-up). * Revert "GroupProcedure: ensure that internal queue is emptied on deinit" This reverts commit f2b7176fc8a96e841c8829f8d3b903633c50e883. * GroupProcedure: ensure that internal queue is emptied on deinit Previously, a GroupProcedure that was created and released but never added to a queue would leak the child operations on its internal OperationQueue. To ensure that it is safe to release a GroupProcedure in all circumstances, add a `deinit` handler that explicitly cancels all operations on the queue, and also ensures that the queue is not suspended (so the queue will handle the clean-up). * Procedure: Use an autoreleasepool in `start()` override Replicate the `NSOperation.start()` autorelease behavior by pushing an autoreleasepool before calling `main()`, and popping after `main()` returns. This is particularly important because we override the default `start()` and `main()` behavior, and our `main()` calls the Procedure subclass’s `execute()` (and we need to ensure that `execute()`, which is running on a background thread, has an autoreleasepool). * Resolves cancellation race condition in Network*Procedure (#627) The internal cancel observer should be a DidCancelObserver. * Adds step to CI for CocoaPod integration (#630) * [OPR-630]: Adds TryProcedureKit trigger * [OPR-630]: Sets the correct commit * [OPR-630]: Lowercase pipeline name * [OPR-630]: Fixes a pipeline typo * [OPR-630]: Renames cocoapods branch in TryProcedureKit * Fixes copy/paste typos (#634) Fixes #633. * Supports result injection in NetworkProcedure (#632) Closes #631. * [OPR-32]: Makes NetworkProcedure conform to OutputProcedure * [OPR-632]: Adds convenience API for injecting payload from network * [OPR-632]: Adds tests for injectPayload(fromNetwork:) * Removes the fatal override of waitUntilFinished() (#635) * Adds UIProcedure & AlertProcedure (#592) UIProcedure & AlertProcedure * ProcessProcedure improvements & thread-safety (#639) * Move ProcessProcedureTests to the "Mac Tests" group * ProcessProcedure thread-safety `NSTask`/`Process` is listed as a Thread-Unsafe …
danthorpe
added a commit
that referenced
this pull request
Aug 25, 2017
* Fixes OperationQueue.delegate crash (SR-192) (#353) * Add failing test test__SR_192_OperationQueue_delegate_weak_var_thread_safety: Tests race condition (and crash) involving OperationQueue’s weak delegate var. * Fix for OperationQueue.delegate crash (SR-192) The underlying error is in Swift < 3.0, with concurrent reads of weak properties. See: https://bugs.swift.org/browse/SR-192 This change wraps the public delegate property with an NSLock. It also sets it to nil first-thing in deinit to safely get rid of it. * Simplistic support for CKLimitExceeded error handling (#294) * [OPR-294]: Initial work adding built in support for CKLimitExceeded * [OPR-294]: Rewrite with support for nil response * [OPR-294]: Adds support for adding error handlers in bulk * [OPR-294]: Fixes some comments * [OPR-294]: Moves error handling to CloudKitError * [OPR-294]: Adds BatchProcessErrorType This is only needed for CKMarkNotificationsOperation * [OPR-294]: Renames error protocols * [OPR-294]: Adds support for batch processing * [OPR-294]: Adds & Refactors for tests * [OPR-294]: Minor tweaks * [OPR-294]: Further tweaks * [OPR-294]: Fixes error in bisect * [OPR-294]: Adds API to replace the configure block outright * [OPR-294]: Fixes failing tests * [OPR-294]: Refactors stress tests condition * Adds TaskOperation (#355) * [OPR-313]: Adds TaskOperation * [OPR-313]: Adds more test coverage * [OPR-313]: Adds header documentation * Vastly improves thread safety in Operations (#358) * FIX: GroupOperation.operations contains the initial operations twice after beginning to execute. Cause: `GroupOperation.execute()` calls `GroupOperation.addOperations(operations)`, which then re-adds the operations back to the operations array. Solution: Added a private **`_addOperations()`** method to `GroupOperation` with an additional flag to override this behavior - used in `GroupOperation.execute()`. `addOperations()` now calls this private implementation method. * Operation.cancel(), Operation.finish() thread-safety - `Operation.cancel()` now acquires the stateLock. - `Operation.finish()` now acquires the stateLock. - `stateLock` is now NSRecursiveLock(). - var `Operation.cancelled` is thread-safe. - var `Operation.errors` is thread-safe. - Explicitly send KVO notifications on NSOperation keyPaths at the right times, avoiding lots of unnecessary notifications. - Removed “State” KVO notifications. (Previously used to trigger NSOperation isExecuting/isFinished notifications, which are now triggered explicitly.) - Added missing operationWillFinish() call to finish(). - operationDidFinish() now happens after the state has been set to .Finished. - `Operation.cancelWithError(errors)` now asserts if it’s called while the Operation is finishing or finished. * Operation.main() thread-safety, Operation.disableAutomaticFinishing - `Operation.main()` acquires the stateLock when appropriate. - `Operation.main()` manually sends the isExecuting NSOperation KVO notifications when setting executing state. - Added ability to disable Operation’s automatic calling of finish(), with `init(disableAutomaticFinishing: Bool)`. (Defaults to existing behavior - i.e. false.) * GroupOperation improvements (finish and thread-safety) - GroupOperation should only finish() after its children have finished. - `GroupOperation._addOperations()` acquires the stateLock. - `GroupOperation._addOperations()` cancels new child operations if the GroupOperation is cancelled. * RepeatedOperation.addNextOperation() must check cancelled - RepeatedOperation.addNextOperation() now checks cancelled status. * Added new cancellation-related tests * Added new GroupOperation tests * Added Operation KVO notification tests (for NSOperation keyPaths) * Fixed spurious commit * Handle more possible cases in Operation.main() - Check that the Operation is not already executing. - Check that the Operation has not been finished by a WillExecute observer (either directly or as a side-effect of something else). Added a test case that demonstrates this possibility. * Add missing super.init() calls * More GroupOperation cancelling fixes - Changed the internal WillCancelObserver to a DidCancelObserver to ensure that the cancelled state has been set prior to cancelling child operations. (This ensures that side-effects of propagating cancellation to child operations - like RepeatedOperation attempting to add the next operation - can safely check the cancelled status.) * GroupOperation should not call queue.cancelAllOperations() Calling queue.cancelAllOperations() also cancels the finishingOperation, which skips properly waiting until all other child operations are finished. Fixed test. * Added willProduceOperation method to OperationQueueDelegate, fix GroupOperation handling of child-produced operations Informational method only. This enables GroupOperation to add child-produced operations to its internal operations array, and thus cancel them when the GroupOperation is cancelled. Added tests. * GroupOperation should ignore queue delegate calls from other queues Added missing guard at the top of the queue delegate methods in GroupOperation. Added test to illustrate simple failure case this change covers. * Refactor lock usage in Operation.finish() and .cancel() - Refactor lock usage to hold the stateLock only when necessary or manipulating internal state, and *not* when sending KVO notifications or notifying observers. - Improvements and fixes to KVO Notification Tests. * Further refactor lock usage in Operation (.execute()) - Refactor lock usage in `Operation.execute()` to hold the stateLock only when necessary or manipulating internal state, and *not* when sending KVO notifications or notifying observers. * Add a number of new StressTests that previously failed/crashed New tests have support for a `batches` parameter. * Initial fix for Logging-related crashes (thread-safety issues) - `Operation._log` must not be a lazy var. From the Swift book: > If a property marked with the lazy modifier is accessed by multiple threads simultaneously and the property has not yet been initialized, there is no guarantee that the property will be initialized only once. For more: https://bugs.swift.org/browse/SR-1042 - `Operation.log` must be thread-safe. Initial fix involves capturing a copy of the logging context (settings + operationName) at the time of access of `Operation.log`, returning that captured context as a LoggerType, and surrounding access of .log with a Read/Write lock. - LogManager properties must be thread-safe. * Refactor lock usage in GroupOperation - var `GroupOperation.operations` is now thread-safe. - GroupOperation now utilizes a private CanFinishOperation to safely transition to executing the finishingOperation. (See code & comments.) - GroupOperation now has its own lock that is used sparingly to protect finishing state. - `GroupOperation._addOperation()` now utilizes the groupFinishLock. * Minor tweaks - `Operation.stateLock` should remain private. * SwiftLint clean-up * Refactor lock usage in GroupOperation - Refactor lock usage to hold the groupFinishLock only when necessary or manipulating internal state, and *not* when sending KVO notifications, notifying observers, or changing additionalOperations state (which might send KVO notifications or notify observers). * Clean-up - Remove asserts from `Operation.cancelWithErrors()`. Operation cancellation methods should be safe to call at any time without asserting. - Other minor tweaks. * Clean-up - Moved NSOperationKeyPaths to extension NSOperation.KeyPath enum. * Clean-up * Clean-up - Remove unneeded `self.` * Clean-up * Clarify docs & re-formatting * Add new inits to Queue (NSQualityOfService and qos_class_t) Per code review. * Clean-up of GroupOperation * Make Operation.cancel() final (#359) Per discussion in: https://github.com/danthorpe/Operations/pull/293 https://github.com/danthorpe/Operations/pull/358#discussion_r70167086 * Supports composing simple types for Result injection (#362) * [OPR-362]: Linting whitespace changes * [OPR-362]: Adds support for composing “executors” inside a final Operation type This is a convenience class to aid adoption of _Operations_ without requiring types to subclass Operation. Instead, classes only need to conform to Executor, and then can use the Execute class, which support cancellation, and result injection. * Supports async executors (#363) * Fixes a finished log message (#365) The "Operation Did finish" log was using the opposite logic for error logging * Group's internal queue is non-public; exposes appropriate properties (#361) * Make GroupOperation's internal queue non-public, and expose appropriate properties on GroupOperation - Make GroupOperation.queue ~private~internal. (So it can be tested.) - Expose appropriate run-time editable properties of the GroupOperation’s queue as properties on GroupOperation. Specifically: - public var maxConcurrentOperationCount: Int - public var suspended: Bool - public var qualityOfService: NSQualityOfService - Add tests. * [OPR-361]: Support underlying queue in Group * GatedOperation cancels composed operation when gate is closed (#377) * [OPR-377]: Adds early exit with guard * [OPR-377]: Refactors GatedOperation execute * [OPR-377]: Fixes typo * Result Injection protocol improvements (#378) * [OPR-378]: Updates result injection APIs * [OPR-378]: Adds unit tests * [OPR-378]: Removes unnecessary weak self capture * Fixes dependency gets added twice if it's direct & indirect (#379) * [OPR-379]: Adds a failing unit test * [OPR-379]: Makes indirect dependencies unique set * Removes TaskOperation from non-macOS platforms (#382) * Removes AlertPresentation mutual exclusion (#383) * Adds IgnoredCondition (#385) * Filters out indirect dependencies which have already been added (#386) * Fixes issues with ignored condition (#390) This means that conditions which are ignored mean that the attached operation does not execute, but also does not finish with an error. It’s a nicer use case than GatedOperation. This works by checking the OperationResult for .Ignored and then only cancel() instead of cancelWithError(). Note that if the operation also has .Failed(errors) condition result, in addition to .Ignored then the operation will still not run but this time with errors (as expected). Note that if the operation also has .Satisfied condition result, in addition to .Ignored then the operation will not run, but without errors. * NoFailedDependenciesCondition supports ignoring cancelled operations (#397) Fixes #396. * [OPR-396]: NoFailedDependenciesCondition support ignoring cancels * [OPR-396]: Refactors initializer * [OPR-396]: Renames the condition * Ability to add configuration to the next (retried) CloudKitOperation (#395) * Adds CloudKitOperation.setPrepareForRetryHandler() * Adds BatchedCloudKitOperation.setPrepareForNextOperationHandler() * Clean-up * Updated new APIs, added documentation -Simpler, cleaner, better APIs. -Added documentation and examples for the new APIs. * Add documentation for BatchedCloudKitOperation. * Updates project header (#399) * [OPR-399]: Updates the header * [OPR-399]: Updates the README to point to the new URL for header * Updates guidelines (#400) * [OPR-400]: Updates copyright holders to “ProcedureKit” * [OPR-400]: Adds a code of conduct * [OPR-400]: Fixes a markdown formatting issue * [OPR-400]: Adds CONTRIBUTING guidelines * [OPR-400]: Moves CONTRIBUTING to .github directory * [OPR-400]: Removes an empty section * [OPR-400]: Adds instruction on adding verbose logs. * [OPR-400]: Updates CONTRIBUTING guideline * [OPR-400]: Updates README too * [OPR-400]: Fixes some typos * Creates ProcedureKit project (#401) * [OPR-401]: Sets up ProcedureKit project * [OPR-401]: Adds ProcedureKitMobile This will cover iOS & watchOS * [OPR-401]: Adds ProcedureKitTV * [OPR-401]: Fixes Runtime Search Paths * [OPR-401]: Adds StressTests * [OPR-401]: Adds ProcedureKitMac * [OPR-401]: Enables code coverage on all testable schemes * [OPR-401]: Adds ProcedureKitCloud * [OPR-401]: Changes to module imports * [OPR-401]: Changes Cloud to latest deployment versions * ProcedureKit CI - Stage 1 (#403) * [OPR-403]: Changes Stress Tests to only run as part of the ProcedureKitMac scheme * [OPR-403]: Changes Cloud minimum target versions * [OPR-403]: Adds tests to CI - ProcedureKit macOS * [OPR-403]: Fixes Operations mac tests * [OPR-403]: Fixes Operations tests 2 * [OPR-403]: Fixes Swift version to 2.2 * [OPR-403]: Moves common scripts around * [OPR-403]: Updates scripts * [OPR-403]: Changes to the Fastlane name for mac * [OPR-403]: Updates build dependencies * [OPR-403]: Sets the correct destination platform * [OPR-403]: Updates scan invocation * [OPR-403]: Updates Fastfile * [OPR-403]: Trying to use which to find bundle * [OPR-403]: Using quotes * [OPR-403]: Adds setup first * [OPR-403]: Putting the whole setup into quotes * [OPR-403]: Attempting to add multiple lines to the command * [OPR-403]: Puts it all on one line * [OPR-403]: Adds more ProcedureKit steps * [OPR-403]: Fixes error in Stress Tests build settings * [OPR-403]: Pipline Uploads * [OPR-403]: Fixes pipelines * [OPR-403]: Uses pipeline upload correctly * [OPR-403]: Fixes error in mobile tests * [OPR-403]: Adds watchOS * [OPR-403]: Removes automatic code signing * [OPR-403]: Comments out watchOS builds * [OPR-403]: Adds TV * [OPR-403]: Removes ad-hoc code signing * [OPR-403]: Fixes Operations iOS * [OPR-403]: Sets iPhone Developer automatic code signing * [OPR-403]: Updates buildkite agent tags for iOS Simulator * [OPR-403]: Sets the development team in xcargs * [OPR-403]: Enables automatic code signing without a team set * [OPR-403]: Fixes issues with code signing settings for TV * [OPR-403]: Removes the development team * [OPR-403]: Puts everything into a single pipeline * [OPR-403]: Cleans up the pipeline * [OPR-403]: Sets personal team for mobile unit tests * [OPR-403]: Updates the Fastlane lane names * [OPR-403]: Adds a copy frameworks build phase * [OPR-403]: Removes copy files phase * [OPR-403]: Comments out problematic build jobs * [OPR-403]: Removes Operations CI jobs * ProcedureKit CI - Stage 2 (#404) * Update CI dependencies (#409) * [OPR-409]: Updates dependencies and enables pipeline * [OPR-409]: Fixes YML * [OPR-409]: Fully specifies the destination Starting to really not like Fastlane * [OPR-409]: Switches to iOS 10 simulators. * [OR-409]: Sets the developer directory * [OPR-409]: Removes tvOS for Mobile framework * [OPR-409]: Reorders the jobs * Add base types to ProcedureKit (#405) * [OPR-405]: Creates Procedure * [OPR-405]: Sets the Swift version * [OPR-405]: Cleans project * [OPR-405]: Changes to destination * [OPR-405]: Stops using Fastlane for testing macOS * [OPR-405]: Adds initial files for ProcedureQueue * [OPR-405]: Defines ProcedureObserver * [OPR-405]: Adds the default implementation of ProcedureObserver * [OPR-405]: Adds the rest of the observer protocols * [OPR-405]: Adds @available annotations * [OPR-405]: Adds block based observers * [OPR-405]: Adds Protector / DispatchQueue extension * [OPR-405]: Further updates to observers API * [OPR-405]: Adds extension to Operation This is for addCompletionBlock - but will be used for more stuff when we get into dependencies * [OPR-405]: Fixes lint issues * [OPR-405]: Adds Procedure protocol with AbstractProcedure * [OPR-405]: Starts interfaces in AbstractProcedure for execute & finish * [OPR-405]: Adds state transition * [OPR-405]: Refactors Procedure to be protocol based. * [OPR-405]: Adds most of the cancellaton functionality * [OPR-405]: Adds main implementation With a few TODOs * [OPR-405]: Fixes available renames * [OPR-405]: Changes AbstractProcedure back to Procedure * [OPR-405]: Adds Testing framework With TestProcedure class * [OPR-405]: Adds basic API to ProcedureTestCase * [OPR-405]: Updates dependencies * [OPR-405]: Commenting out non mac unit tests Run CI on iOS Simulators is basically impossible on beta version of Xcode. * [OPR-405]: Adds finishing and cancellation tests * [OPR-405]: Adds some finishing tests * Adds Logging (#428) * [OPR-428]: Adds LogSeverity * [OPR-428]: Adds logger * [OPR-428]: Updates logging stuff * [OPR-428]: Adds logging tests * Group (#430) * [OPR-430]: Adds Group * [OPR-430]: Adds initializers to Group * [OPR-430]: Adds add child API to Group * [OPR-430]: Corrects spelling * [OPR-430]: Adds finishing APIs to Group * [OPR-430]: Adds extension of unavailable APIs * [OPR-430]: Adds GroupObserverProtocol * [OPR-430]: Adds error handling and recovery to Group * [OPR-430]: Improves group observers API * [OPR-430]: Adds first group test * [OPR-430]: Adds some basic tests for Group * [OPR-430]: Adds more unit test for Group * [OPR-430]: More tests for group * Adds User Intent (#439) * [OPR-439]: Adds UserIntent to Procedure * [OPR-439]: Adds userIntent to Group * Stress Tests Phase 1 (#442) * [OPR-442]: Adds StressTestCase and completion block stress tests * [OPR-442]: Uses StressLevel directly. * [OPR-442]: Refactors the test case names * [OPR-442]: Refactors to remove StressTestCase Instead the stress function can be added to the base ProcedureKitTestCase * [OPR-442]: Adds group cancel stress test * [OPR-422]: Refactors group stress tests These are currently failing * [OPR-422]: Refactors schemes, as stress tests are run as part of Mac tests * [OPR-442]: Updates Stress Tests batches Uses intermediate BatchProtocol, and exposes a measure API. * [OPR-422]: Changes the active developer directory * [OPR-422]: Adds group child finishing order stress test * [OPR-422]: Fixes incorrect pipeline step * [OPR-422]: Adds more stress tests for Procedure * [OPR-422]: Fixes TestError mistake * [OPR-422]: Changes to use didCancelBlockObserver Instead of didFinishBlockObserver - there might be a subtle bug here. * [OPR-422]: Disables some checks - have identified that there is definitely an error in finishing logic * [OPR-422]: Moves stress tests to their own scheme * [OPR-422]: Adds stress fastlane * [OPR-422]: Trying to see how to trigger stress tests * [OPR-422]: Removing - * [OPR-422]: Changes the trigger to ProcedureKit * [OPR-422]: Add the pipeline update step back * [OPR-422]: Fixes yml * [OPR-422]: More changes to pipeline template * [OPR-422]: Fixes the slug This is case sensitive! * [OPR-422]: Triggers a different pipeline stress tests * [OPR-422]: Adds commit message to stress test build * [OPR-422]: Modifies measure to be a little quicker * [OPR-422]: Updates baselines with Mac Pro * [OPR-422]: Fixes mistake with finishing from cancel * Fix issue with newlines in pipeline upload (#445) * [OPR-445]: Removes message from upload script * [OPR-422]: Puts the commit back * Initial work on Result Injection (#446) * Adds Dependencies & Conditions (#429) * [OPR-429]: Adds Condition protocol and class * [OPR-429]: Adds conditions to procedure and queue * [OPR-429]: Adds tests for Conditions Also adds XCTAssertProcedure functions to make verifying Procedure behaviour more consistent. * [OPR-429]: Adds remaining unit tests for conditions Still got Ignored Condition to add * [OPR-429]: Fixes some documentation * [OPR-429]: Performs the stress tests in the same build * [OPR-422]: Adds stress tests for conditions * [OPR-429]: Adds IgnoredCondition * ProcedureKitError (#437) * [OPR-437]: Regorganized the Core group * [OPR-437]: Refactors Errors into ProcedureKitError * Completes Result Injection API test coverage (#447) * [OPR-447]: Sorts out ResultInjection * [OPR-447]: Completes result injection tests * Fixes Xcode 8 GM issues (#463) * BlockProcedure (#450) * [OPR-450]: Adds BlockProcedure * [OPR-450]: Adds unit tests for map and block procedures * [OPR-450]: Adds some stress tests for block procedure * [OPR-450]: Updates stress tests * [OPR-450]: Fixes Xcode 8 GM escaping issue * [OPR-450]: Papers over some possible issues with finishing. In many cases the `should finish after cancelling` logic is returning false. * [OPR-450]: Removes some excessive logging * [OPR-450]: Adjusts variation to 15% * Mutual exclusive conditions (#448) * [OPR-448]: Adds MutualExclusion * [OPR-448]: Adds support for adding dependencies for mutual exclusion * [OPR-448]: WIP on mutual exclusivity * [OPR-448]: Finishes off test cases for mutual exclusivity * [OPR-448]: Refactors add condition API to attach condition I want to make the API consistent - but not choose consistency over intent. So, `add(dependency: myDependency)` makes sense - as it signals that the dependency is already managed by some other queue/system. Where as for a Condition, we specifically _attach_ it to Procedure instance, and it does not (ideally should not) be managed outside the Procedure. So, I want the concept of “attaching conditions to procedures” to be the language which is used to describe the behaviour. * DelayProcedure (#449) * [OPR-449]: Adds delay procedure * [OPR-449]: Adds DelayProcedure tests * Renames Group to GroupProcedure (#468) * Adds ProcedureKit.podspec (#467) * Adds NegatedCondition (#471) * Adds SilentCondition (#472) * Procedure finishing fixes (#474) * Resolve finishing issues related to FinishingFrom. * Add StressTest that covers concurrent calls to finish() * Revert ProcedureKitTestCase expectation fulfillment back to the main queue. * Adds BlockCondition (#473) * Adds NoFailedDependenciesCondition (#470) * Adds TimeoutObserver (#475) * [OPR-475]: Adds TimeoutObserver * [OPR-475]: Fixes issues with TestProcedure It was not correctly delaying. * Procedure name and identity (#478) * [OPR-478]: Adds name and Identity * [OPR-478]: Fixes some failing tests * [OPR-478]: Fixes another failing name test * Adds BlockObserver (#480) * [OPR-480]: Adds BlockObserver * [OPR-480]: Tweaks to stress tests * Adds ComposedProcedure & GatedProcedure (#487) * RepeatProcedure (#488) * [OPR-488]: Initial work on RepeatProcedure * [OPR-488]: Adds remaining test coverage * RetryProcedure (#491) * [OPR-491]: Adds RetryProcedure * [OPR-491]: Unifies the generic init pattern for repeat and retry procedures * Adds support for Capabilities (#492) * [OPR-492]: Fixes incorrectly spelt protocol * [OPR-492]: Adds Capability Including CapabilityProtocol, GetAuthorizationStatus, Authorize, AuthorizedFor * Adds BackgroundObserver (#476) * [OPR-476]: Fixes stress tests * [OPR-476]: Adds BackgroundObserver * [OPR-476]: Gets the Mobile test suite working * [OPR-476]: Switches code coverage on * [OPR-476]: Adds missing callback This was causing a failing unit test * [OPR-476]: Removes unnecessary build phase * [OPR-476]: Finishes BackgroundObserver tests * [OPR-476]: Removes verbose logging in test case * Adds FilterProcedure (#496) * [OPR-496]: Adds FilterProcedure * [OPR-496]: Adds filter method for when Result is a sequence * Adds ReduceProcedure (#497) * [OPR-497]: Adds ReduceProcedure * [OPR-497]: Refactors Map, Filter adds FlatMap MapProcedure is really a TransformProcedure. MapProcedure and FilterProcedure are now simple subclasses of ReduceProcedure, along with FlatMapProcedure. * Adds NetworkObserver (#498) * [OPR-498]: Adds NetworkObserver Additionally, this updated ProcedureKitTestCase to automatically add async expectation fulfills around operations which might be produced by a procedure. * [OPR-498]: Refactors ProcedureKitTestCase slightly for Swift 3 conventions. * Adds Location.Capability (#499) * [OPR-499]: Adds ProcedureKitLocation framework * [OPR-499]: Supports sychronous dispatch onto the main queue This is safe to call if already on the main queue. * [OPR-499]: Adds Capability.Location * Adds UserLocationProcedure (#500) * [OPR-500]: Adds UserLocationProcedure * [OPR-500]: Removes unneeded error struct * [OPR-500]: Fixes issue with tvOS * Corrects minimum deployment targets (#503) Fixes #501 * [OPR-501]: Fixes issues with deployment versions * [OPR-501]: Setting tvOS to 9.2 * Adds ReverseGeocodeProcedure (#502) * [OPR-502]: Adds ReverseGeocodeProcedure * [OPR-502]: Adds ProcedureKitMobile as a build dependency * [OPR-502]: Fixes a mistake where macOS location tests were requiring iOS simulator * [OPR-502]: Uses gym to ensure iOS builds ProcedureKitMobile before testing Location * [OPR-502]: Use scan instead of gym This is a hack. I want to make sure that when we test ProcedureKitLocation on iOS we have build ProcedureKitMobile. * Adds ReverseGeocodeUserLocationProcedure (#504) * [OPR-504]: Adds/renames files * [OPR-504]: Adds ReverseGeocodeUserLocationProcedure * [OPR-504]: Rounds out the unit tests on ReverseGeocodeUserLocationProcedure * Makes procedures open where appropriate (#510) * Refactors BlockProcedure (#511) * Adds AnyProcedure (#516) * [OPR-516]: Removes import foundation This is done by the prefix header * [OPR-516]: Adds AnyProcedure * [OPR-516]: Uses the correct underlying queue throughout AnyProcedure * Fixes regression of failing release build (#518) * Renames AuthorizationStatusProtocol to AuthorizationStatus (#519) * Renames capability reated procedures (#520) * Renames attach(condition: Condition) to add (#521) * Adds Capability.CloudKit (#523) * [OPR-523]: Adds Capability.CloudKit * [OPR-523]: Enables CI builds for CloudKit stuff on iOS and tvOS * Adds ProcedureKitNetwork framework (#524) * [OPR-524]: Adds ProcedureKitNetwork framework * [OPR-524]: Adds Network to CI jobs * [OPR-524]: Renames Stress Tests job * [OPR-524]: Shares the network scheme * [OPR-524]: Imports Foundation instead of Cocoa * [OPR-524]: Forces Stress Tests onto a non-simulator agent * Adds NetworkDataProcedure (#525) * [OPR-525]: Adds NetworkDataProcedure * [OPR-525]: Fixes up some unit tests * [OPR-525]: Adds missing test coverage * Moves TestableNetwork into TestingProcedureKit framework (#526) * Refactors injectDependency API to be an extension on ProcedureProtocol instead. (#527) * Adds transform block result injection API (#528) * [OPR-528]: Refactors result injection Uses an intermediatory injectResult(from: via:) API, which allows the caller to provide a throwing block to transform the result into the requirement. * [OPR-528]: Removes unneeded return * [OPR-528]: Fixes error in ProcedureKitLocation * Adds default empty implementations some queue delegate methods (#531) Only added the will-do-something ones. Fixes #530 * Adds space in the repo for presentations (#533) * [OPR-533]: Adds CocoaHeads Stockholm talk Contact @danthorpe if you want the original Keynote file. * [OPR-533]: Adds Sky-UK iOS Community Talk * [OPR-533]: Adds a presentations README * Disables the log for AnyProcedure (#534) * Fixes bug where GroupProcedure collects errors from children after its been cancelled (#532) * [OPR-532]: Adds failing test * [OPR-532]: Checks cancelled state of the group We can exit this delegate callback early if the group has already been cancelled. * [OPR-532]: Removes default implementation of willFinish It seems that adding default implementations here causes some odd behaviour / intermittent crash where this is overwritten in the QueueDelegate. * [OPR-532]: Fixes a unit test which is now mis-counting errors. * Adds .then { } API (#536) * [OPR-176]: Adds then extension on Operation * [OPR-176]: Implements .then { } API * [OPR-176]: Adds enqueue method to a collection of Operations * [OPR-176]: Fixes header docs * Removes default argument for session in NetworkDataProcedure (#538) * Tweaks the cancel block procedure stress tests (#539) There might be an underlying issue. As normally a batch of 10_000 finishing in ~ 5 seconds. But sometimes fails because it times out, meaning that an expectation is not getting fulfilled. * Moves ProcedureKit imports to umbrella headers (#540) * [OPR-540]: Putting the appropriate imports into umbrella headers * [OPR-540]: Fixing issues with importing ProcedureKit into TestingProcedureKit * Updates ProcedureKit podspec with subspecs (#508) * [OPR-508]: Lints podspec without an warnings or errors. * [OPR-508]: Fixes errors running tests * Adds ResilientNetworkProcedure (#537) * [OPR-537] Adds ResilientNetworkProcedure * [OPR-537]: Updates retry request with error code * [OPR-537]: Adds edge case for ResilientNetworkProcedure In some situations, the HTTP status code might well require (depending on the behaviour) a retry. * [OPR-537]: Fixes simple unit tests * Refactor ResultInjection to use PendingValue enum (#541) * [OPR-541]: Refactors ResultInjectionProtocol to use PendingValue enum * [OPR-541]: Renames ResultInjectionProtocol to ResultInjection * Fixes BlockProcedure stress tests (#544) * [OPR-544]: Fix test__cancel_block_procedure() failures It was possible for the testing BlockProcedure to finish prior to the `block.cancel()` call, which would result in some of the BlockProcedures never cancelling (as they had finished first), and a failing test. Fixed by using a semaphore inside the BlockProcedure’s block. Additionally, the test now waits for all BlockProcedures to cancel *and* finish. * [OPR-544]: Added a new stress test for BlockProcedure cancelling & finishing behavior (allowing for possible races between cancelling and finishing) * Fixes ExclusivityManager synchronization bug (#545) Fixes #543 The ExclusivityManager was using `DispatchQueue.initiated`, which returns a global **concurrent** queue, however its internals are dependent upon **serial** execution of add/remove. Modified to use a serial queue. * Adds ResultProcedure and overloads injectResult(from:) (#546) * Adds HTTPResult<Payload> (#547) * Fix test crashes caused by QueueTestDelegate (#549) QueueTestDelegate was not thread-safe. This could result in crashes running random tests. Fixed by making QueueTestDelegate’s methods thread-safe. * Adds ProcedureKitTestCase wait function that takes an array (#552) * Adds TestingProcedureKit podspec (#553) * Adds Mutual Exclusivity concurrency testing (#550) * Add ConcurrencyTestCase Exposes functionality to test operation concurrency. * Add Mutual Exclusivity concurrency tests * Refactored ConcurrencyTestCase * Refactored ConcurrencyTestCase * Adds didExecuteObserver (#554) * [OPR-554]: Adds code with failing test * [OPR-554]: Calls didExecuteObservers * [OPR-554]: Fixes a typo * [OPR-554]: Adds some documentation to the DidExecuteObserver * Fixes mistake in Fastfile (#557) * [OPR-557]: Fixes error in Fastfile * [OPR-557]: Removes duplicate scan I remember now, as part of location, we used to build Mobile too - because there was a dependency on iOS. But this has since been removed. * Fixes release configuration issues with Xcode 8.1 (#559) Fixes #548 * [OPR-548]: Fixes issue with Xcode 8.1 release configuration * [OPR-548]: Fixes some SwiftLint warnings. * [OPR-548]: Fixes Xcode project warnings in Xcode 8.1 * Adds GroupProcedure concurrency tests (#556) * Add GroupConcurrencyTestCase * Add GroupProcedure.maxConcurrentOperationCount tests * Fixes registrar typo (#562) * Adds NetworkDownloadProcedure. (#565) The implementation for class and test is largely inspired by `NetworkDataProcedure` class. * Adds NetworkUploadProcedure. (#567) * Add NetworkUploadProcedure. The implementation class and test has been largely inspired by `NetworkDataProcedure`. The requirement type is currently a pending value of a tuple. Maybe would it make more sense to create a dedicated struct to add more clarity in the case of dependencies injection ? * Use an `HTTPRequirement` struct for requirement. As discussed, an `HTTPRequirement` struct is used instead of a tuple. * Fixes Condition to support ResultInjection (#566) * [OPR-566]: Replaces Condition result with PendingValue<ConditionResult> * [OPR-566]: Refactors how conditions are evaluated This fixes a existing issue where the ConditionEvaluation enum was basically just like ConditonResult, except that it could hold an array of errors. This has been resolved by using an internal error type `ProcedureKitError.FailedConditions` to collect multiple errors from failed conditons, so that we can reduce a sequence of `ConditionResult`s into a single one. * [OPR-566]: Explicitly adds a Result typealias * [OPR-566]: Fixes error where cancelled conditions would throw a fatal error. * [OPR-566]: Removes verbose log * Adds ProcessProcedure. (#570) * Add ProcessProcedure. The class has been largely inspired by the original `TaskOperation`. Refers to #568. * Apply requested changes. Correctly implement `Equatable` for sub-error enum. Use camel case for the enum. Fix closure self semantics. * Calls TestableReverseGeocoder completionHandler on the main queue (#572) * Improves performance of adding observers * Procedure.add(observer:) performance tweak Append directly to the protected observers array. * Fix swiftlint `variable_name` warning * Makes ProcedureQueue.add(operation: Operation) method open (#578) * Fixes NetworkObserver thread-safety (#576) (#577) * Fix NetworkObserver thread-safety By fixing NetworkActivityController `start()`/`stop()` thread-safety. (And making private methods/variables private.) * NetworkObserver test fixes * Reduce test delay * Additional GroupProcedure tests (#579) * Adds CloudKitProcedure (#542) * [OPR-542]: Adds shell of CloudKit files * [OPR-542]: Adds extensions for CKOperation * [OPR-542]: Adds extensions for CKDatabaseOperation * [OPR-542]: Adds extensions for CKAcceptSharesOperation * [OPR-542]: Adds extensions for CKDiscoverAllContactsOperation * [OPR-542]: Adds extensions for CKDiscoverAllUserIdentifiesOperation * [OPR-542]: Adds extensions for CKDiscoverUserIdentitiesOperation * [OPR-542]: Adds extensions for CKDiscoverUserInfosOperation * [OPR-542]: Adds extensions for CKFetchDatabaseChanges * [OPR-542]: Adds extensions for CKFetchDatabaseChangesOperation * [OPR-542]: Adds extensions for CKFetchRecordChangesOperation * [OPR-542]: Moves the interface into the extension files * [OPR-542]: Fixes dispatchQueue * [OPR-542]: Adds extensions to CKFetchRecordsOperation * [OPR-542]: Adds extensions for CKFetchRecordZoneChangesOperation * [OPR-542]: Removes unnecessary public properties * [OPR-542]: Adds extensions for CKFetchRecordZonesOperation * [OPR-542]: Adds extensions for CKFetchShareMetadataOperation * [OPR-542]: Adds extensions for CKFetchShareParticipantsOperation * [OPR-542]: Adds extensions for CKFetchSubscriptionsOperation * [OPR-542]: Adds extensions for CKMarkNotificationsReadOperation * [OPR-542]: Adds extensions for CKModifyBadgeOperation * [OPR-542]: Adds extensions for CKModifyRecordsOperation * [OPR-542]: Adds extensions for CKModifyRecordZonesOperation * [OPR-542]: Adds extensions for CKModifySubscriptionsOperation * [OPR-542]: Adds extensions for CKQueryOperation * [OPR-542]: Adds missing APIs for error handlers * [OPR-542]: Adds testable CK operation classes * [OPR-542]: Adds tests for CKOperation, CKDatabaseOperation and CKAcceptSharesOperation * [OPR-542]: Removes missing test cases from tvOS * Small typo fix * Adds tests for CKDiscoverAllContactsOperation * Adds tests for CKDiscoverAllUserIdentitiesOperation * Adds tests for CKDiscoverUserIdentitiesOperation * Adds tests for CKDiscoverUserInfosOperation * [OPR-542]: Adds tests for CKFetchAllChanges protocol * [OPR-542]: Adds tests for CKFetchDatabaseChangesOperation * [OPR-542]: Adds tests for CKFetchNotificationChangesOperation * [OPR-542]: Adds tests for CKFetchRecordChangesOperation * [OPR-542]: Adds tests for CKFetchRecordsOperation * [OPR-542]: Added missing `recordZoneFetchCompletionBlock` for CKFetchRecordZoneChangesOperationProtocol extensions * [OPR-542]: Adds tests for CKFetchRecordZoneChangesOperation * [OPR-542]: Adds tests for CKFetchRecordZonesOperation * [OPR-542]: Adds tests for CKFetchShareMetadataOperation * [OPR-542]: Adds tests for CKFetchShareParticipantsOperation * [OPR-542]: Adds tests for CKFetchSubscriptionsOperation * [OPR-542]: Minor typo fix To follow the original API naming, change `setMarkNotificationReadCompletionBlock` to `setMarkNotificationsReadCompletionBlock`. * [OPR-542]: Adds tests for CKMarkNotificationsReadOperation * [OPR-542]: Adds tests for CKModifyBadgeOperation * [OPR-542]: Adds tests for CKModifyRecordsOperation * [OPR-542]: Adds tests for CKModifyRecordZonesOperation * [OPR-542]: Adds tests for CKModifySubscriptionsOperation * [OPR-542]: Adds tests for CKQueryOperation * [OPR-542]: Fixes whitespace in test cases * [OPR-542]: Adds CloudKitProcedure<CKAcceptSharesOperation> tests * [OPR-542]: Fixes tests on tvOS. Again. * [OPR-542]: Adds tests for CKDiscoverAllContactsOperation * [OPR-542]: Adds tests for CKDiscoverAllUserIdentitiesOperation * [OPR-542]: Adds tests for CKDiscoverUserIdentitiesOperation * [OPR-542]: Adds tests for CKDiscoverUserInfosOperations * [OPR-542]: Adds tests for CKFetchDatabaseChangesOperation * [OPR-542]: Unifies testing of common properites * [OPR-542]: Adds tests for CKFetchNotificationChangesOperation * [OPR-542]: Adds tests for CKFetchRecordChangesOperation * [OPR-542]: Adds test for CKFetchRecordsOperation * [OPR-542]: Adds tests for CKFetchRecordZoneChangesOperation * [OPR-542]: Adds test for CKFetchRecordZonesOperation * [OPR-542]: Adds tests for CKFetchShareMetadataOperation * [OPR-542]: Adds tests for CKFetchShareParticipantsOperation * [OPR-542]: Fixes inconsistently named tests * [OPR-542]: Adds tests for CKFetchSubscriptionsOperation * [OPR-542]: Adds tests for CKMarkNotificationsReadOperation * [OPR-542]: Adds tests for CKModifyBadgeOperation * [OPR-542]: Adds tests for CKModifyRecordsOperation * [OPR-542]: Adds tests for CKModifyRecordZonesOperation * [OPR-542]: Adds test for CKModifySubscriptionsOperation * [OPR-542]: Adds test for CKQueryOperation * [OPR-542]: Adds tests which trigger default retry behavior * [OPR-542]: Adds tests for set/get all errors handlers * [OPR-542]: Adds tests for custom error handlers * Adds Profiler (#573) * Implement Profiler as specified in #569. The implmentation is largely inspired by the original `Profiler.swift` file. * Add first set of tests. The test has been largely inspired by the original tests classes. I have a commented test taht fails. After trying to debug for a while, I suspect maybe an issue inside GroupProcedure or the original implementation. * Apply requested changes. Perform changes as requested. * Adds public initialiser to HTTPRequirement (#586) Declaring a constructor for the `HTTPRequirement` allows the construction of the struct without any issue. * Removes GroupProcedureObserver protocol (#583) Instead ProcedureObserver takes over this responsibility. * [OPR-574]: Cleans up white space & style for consistency * [OPR-574]: Uncomments failing test * [OPR-574]: Adds new API to ProcedureObserver protocol * [OPR-574]: Removes temporary print statements * [OPR-574]: Refactors to support willAdd & didAdd observer callbacks. * [OPR-574]: Removes commented out line. * [OPR-574]: Removes group observers. * [OPR-574]: Removes extraneous logging in some tests * [OPR-574]: Makes add(observer:) open for overriding * [OPR-574]: Adds some documentation comments to public interfaces * Supports Arbitrary mutual exclusion category names (#587) Fixes #580. * [OPR-580]: Supports arbitrary mutual exclusion category names * [OPR-580]: Fixes default category for AuthorizedFor * Adds NetworkReachableProcedure (#563) * [OPR-563]: Adds Reachability functionality * [OPR-563]: Adds additional files for testing support * [OPR-563]: Adds tests for Reachability * [OPR-563]: Adds basis of NetworkReachableProcedure * [OPR-563]: Adds simple network reachability procedure tests * [OPR-563]: Fixes issue with Protector write being synchronous. * [OPR-563]: Refactors DeviceReachability slightly * [OPR-563]: Changes Protector behavior back to be non-blocking * [OPR-563]: Fixes Reachability.Device * [OPR-563]: Adds NetworkProcedure and ProcedureKitNetworkError * [OPR-563]: Fixes for network error tests * [OPR-563]: Adds remaining tests for Reachable procedure * [OPR-563]: Removes unnecessary logging * Refactors produce API (#588) * Add failing test * Test tweaks * Changes to Procedure.produce(operation:) handling Fixes failing test case, and simplifies execution flow. Changes `willEnqueue()` to `willEnqueue(on: ProcedureQueue)`. `func produce(operation: Operation)` now throws. * Ported additional test case from Operations 3.x. * swiftlint tweak * Fixed mobile tests. * Adds missing equality cases for ProcedureKitError.Context (#591) Fixes #589 * Supports merging collections of ResultInjection Procedures (#593) * [OPR-593]: Adds gather and reduce APIs * [OPR-593]: Removes the rethrows While the nextPartialResult closure can throw, this error is not re-thrown. Instead, because this block is executed after the receiver’s procedures have all finished, the error means that the `ResultProcedure` will finish with an error. * [OPR-593]: Adds test case for throwing closure * [OPR-593]: Refactors gather() so that it is a specialization of new flatMap API * Improves how stress tests are run in CI (#594) * [OPR-594]: Updates pipeline queues * [OPR-594]: Fixes yaml * [OPR-594]: Disables Thread Sanitizer for Stress Tests * [OPR-594]: Uses Release configuration for stress tests * Fix StressTestCase Batch counters thread-safety (#555) (#596) * Fixes public access levels for CKProcedure (#599) * Fixes some RepeatProcedure thread-safety issues (#597) Fix issues identified by an audit and Thread Sanitizer * Fixes Procedure & Support thread-safety (#598) * Change Protector.write() to be synchronous (and optionally return a value from the block) Thread Sanitizer identified a data race caused by the combination of the prior asynchronous `write()` and deinitialization. * Explicitly `import Dispatch` in Support.swift Fixes an occasional Xcode warning display glitch. * Fix Protector.read() to no longer require an `escaping` block * Adds back `Protector.write(_:completion:)` Although, like the new write(_:) method, this is now synchronous. * Wrap all properties of Procedure in a Protector to ensure thread-safety `errors`, `observers`, `directDependencies`, `conditions` (and associated methods) are now thread-safe * Fix comment formatting * Removes @testable import (#600) Exposes NSLock and NSRecursiveLock extensions * Add RepeatProcedure cancellation stress test (#602) * Adds more GroupProcedure test coverage (#603) * Additional / improved GroupProcedure test cases * Remove unused private setter * Refactors of Result Injection APIs (#601) * [OPR-601]: Renamed PendingResult to PendingProfileResult * [OPR-601]: Adds protocols for Input & Output * [OPR-601]: Refactors for InputProcedure & OutputProcedure * [OPR-601]: Refactors ReduceProcedure as a TransformProcedure subclass * [OPR-601]: Refactoring for InputProcedure & OutputProcedure * [OPR-601]: Refactoring Condition to use Result<Bool> * [OPR-601]: Refactors ProcedureKitNetwork result injection * [OPR-601]: Refactors Location for result injection * [OPR-601]: Removes ResultInjection.swift * [OPR-601]: Removes left over properties * [OPR-601]: Tidies up ResultProcedure & TransformProcedure * [OPR-601]: Adds finish(withResult:) API * [OPR-601]: Refactors to use finish(withResult:) * [OPR-601]: Renames HTTPRequirement & HTTPResult * Renames Result to ProcedureResult (#605) * [OPR-605]: Renames Result to ProcedureResult Just to help with any interop issues with antitypical/Result * [OPR-605]: Renames Result to ProcedureResult * Adds AsyncBlockProcedure (#606) * [OPR-606]: Adds AsyncBlockProcedure As a specialization of AsyncResultProcedure * [OPR-606]: Moves async block tests into same file * [OPR-606]: Adds AsyncTransformProcedure * Adds @escaping marker to the FinishingBlock (#607) * Fixes NetworkActivityController internal timer (#608) * NetworkActivityController's delayed hide should occur on the queue Fixes data race. * Remove outdated test * NetworkDataProcedure, NetworkDownloadProcedure, NetworkUploadProcedure thread-safety (#609) * Adds NetworkProcedure (#561) * [OPR-561]: Refactoring ResilientNetworkProcedure - Supports request timeout - Adds HTTPStatusCode where we only even consider retrying client or server errors. - Adds some initial tests * [OPR-561]: Refactors NetworkResilience * [OPR-561]: Refactor to unify reachable & resilience network procedures * [OPR-561]: Adds resilience error handling support This is so that even if the network request “succeeds” but results in say, a server error, we will still trigger retries. * [OPR-561]: Fixes typos * Add missing imports to make Xcode happier (#611) * Add explicit imports to the top of ProcedureKit files This makes Xcode happier. * Add missing imports to the top of ProcedureKitCloud files This makes Xcode happier. * Add missing imports to the top of ProcedureKitMobile files This makes Xcode happier. * Add missing imports to the top of ProcedureKitLocation files This makes Xcode happier. * Fixes BackgroundObserver data race (#614) * Makes NetworkObserver cross-platform (#613) * NetworkObserver and NetworkActivityController cross-platform work On all platforms, the following initializers are available: `NetworkObserver.init(controller: NetworkActivityController)` `NetworkActivityController.init(timerInterval: TimeInterval = 1.0, indicator: NetworkActivityIndicatorProtocol)` To implement your own network activity indicator display, conform to `NetworkActivityIndicatorProtocol`. NetworkActivityController ensures that all accesses of the indicator’s `networkActivityIndicatorVisible` property are serialized on the main queue. On iOS (but *not* in application extensions), the following convenience initializers are available that utilize `UIApplication.shared` to display/hide the network activity indicator in the status bar: `NetworkObserver.init()` `NetworkActivityController.init(timerInterval: TimeInterval = 1.0)` `NetworkActivityController.shared` * [OPR-612]: Moves NetworkObserver into Network framework * [OPR-612]: Moves NetworkObserver into ProcedureKit Keeps iOS non-extension related elements in ProcedureKitMobile * Add documentation * Fixes BackgroundObserver on iOS 8.x (#615) To support iOS < 9.0 and macOS < 10.11, NotificationCenter observers **must** be properly removed, or a crash may result. * Fixes DelayProcedure thread-safety (#616) * Fixes to Location related procedures (#619) * Capability.Location should set its registrar's delegate to nil on deinit. CLLocationManager’s delegate is `unowned(unsafe)`, and we must ensure it is set to nil before the object goes away. The only strong reference to the delegate that Capability.Location sets is stored within Capability.Location. * LocationCapabilityTests tweaks Explicitly set the test CLLocationManager’s `delegate` back to nil. Explicitly wait on `capability.requestAuthorization` to fulfill an expectation. * ReverseGeocodeProcedureTests tweaks * Fix an occasional crash running the Location tests It seems there may be an edge case in CoreLocation triggered when creating (and releasing) lots of CLLocationManager instances (as previously happened when each test, using its own TestableLocationServicesRegistrar, created a “fake” CLLocationManager). Change `TestableLocationServicesRegistrar`’s “fake” CLLocationManager (which is only used to populate a parameter in the delegate callbacks) to a static class variable. * Compiles out SystemConfiguration related stuff from watchOS (#621) * Adds an All subspec (#623) * Adds missing imports in TestingProcedureKit (#625) Noticed this issue after doing some integration testing via CocoaPods * Network*Procedure tweaks (#626) * Resolve cancellation race condition in Network*Procedure Must check `!isCancelled` inside the `stateLock`, or it is possible for a `NetworkDataProcedure`/`NetworkDownloadProcedure`/`NetworkUploadProcedur e` that is cancelled after the `execute()` function is called, but before the acquisition of the `stateLock` inside it, to continue to create a network task. * Mark `task` as `private(set)` The `task` variable should not be set outside of the `NetworkDataProcedure` / `NetworkDownloadProcedure` / `NetworkUploadProcedure`. * Memory leaks fixes highlighted by Visual Memory Debugger (#624) * TimeoutObserver should capture a weak reference to the procedure * RetryIterator should not maintain a strong reference to the RetryProcedure RetryIterator’s RetryFailureInfo (`info`) property is set right before `addNextOperation()` is called, which calls `next()` on the RetryIterator (which then uses the RetryFailureInfo). Ultimately, the RetryFailureInfo contains strong references to the RetryProcedure. And since the RetryProcedure owns the RetryIterator, which owns the RetryFailureInfo… We end up with a reference cycle. As an immediate quick fix, since the RetryFailureInfo is only used in the call to `addNextOperation()`, set it back to `.none` after the call. * Add test to catch reference cycles in RetryProcedure (Fixed by prior commit.) * GroupProcedure: ensure that internal queue is emptied on deinit Previously, a GroupProcedure that was created and released but never added to a queue would leak the child operations on its internal OperationQueue. To ensure that it is safe to release a GroupProcedure in all circumstances, add a `deinit` handler that explicitly cancels all operations on the queue, and also ensures that the queue is not suspended (so the queue will handle the clean-up). * Revert "GroupProcedure: ensure that internal queue is emptied on deinit" This reverts commit f2b7176fc8a96e841c8829f8d3b903633c50e883. * GroupProcedure: ensure that internal queue is emptied on deinit Previously, a GroupProcedure that was created and released but never added to a queue would leak the child operations on its internal OperationQueue. To ensure that it is safe to release a GroupProcedure in all circumstances, add a `deinit` handler that explicitly cancels all operations on the queue, and also ensures that the queue is not suspended (so the queue will handle the clean-up). * Procedure: Use an autoreleasepool in `start()` override Replicate the `NSOperation.start()` autorelease behavior by pushing an autoreleasepool before calling `main()`, and popping after `main()` returns. This is particularly important because we override the default `start()` and `main()` behavior, and our `main()` calls the Procedure subclass’s `execute()` (and we need to ensure that `execute()`, which is running on a background thread, has an autoreleasepool). * Resolves cancellation race condition in Network*Procedure (#627) The internal cancel observer should be a DidCancelObserver. * Adds step to CI for CocoaPod integration (#630) * [OPR-630]: Adds TryProcedureKit trigger * [OPR-630]: Sets the correct commit * [OPR-630]: Lowercase pipeline name * [OPR-630]: Fixes a pipeline typo * [OPR-630]: Renames cocoapods branch in TryProcedureKit * Fixes copy/paste typos (#634) Fixes #633. * Supports result injection in NetworkProcedure (#632) Closes #631. * [OPR-32]: Makes NetworkProcedure conform to OutputProcedure * [OPR-632]: Adds convenience API for injecting payload from network * [OPR-632]: Adds tests for injectPayload(fromNetwork:) * Removes the fatal override of waitUntilFinished() (#635) * Adds UIProcedure & AlertProcedure (#592) UIProcedure & AlertProcedure * ProcessProcedure improvements & thread-safety (#639) * Move ProcessProcedureTests to the "Mac Tests" group * ProcessProcedure thread-safety `NSTask`/`Process` is listed as a Thread-Unsafe Class in the Foundation Framework Thread Safety guide. As such, some major modifications to ProcessProcedure were necessitated. - `init(…)` now takes all the possible configuration parameters for the Process, instead of a Process instance (the only required parameter is `launchPath`) - the ProcessProcedure is now responsible for creating the Process object and managing it - there is no public accessor for the Process object (it’s now an internal implementation detail of ProcessProcedure) - various additional methods / properties were added to expose Process object functionality directly on the ProcessProcedure * Lots of ProcessProcedure tests * Minor tweak * Added more (read-only) properties * Added more tests * Add missing import * [OPR-639]: Very minor tweaks * NetworkProcedure cancellation testing enhancements (#640) * Enhance TestableURLSessionTask and TestableURLSessionTaskFactory cancellation support The behavior now better replicates NSURLSession/NSURLSessionTask behavior on cancellation, including providing the proper error to the completionHandler. * More cancellation tests for NetworkDataProcedure * More cancellation tests for NetworkDownloadProcedure * More cancellation tests for NetworkUploadProcedure * Minor tweak * Minor tweak * Testing after DidExecute improvements/fixes (#643) * Add `checkAfterDidExecute` method to ProcedureKitTestCase Supports executing a block after a procedure has finished running its `execute()` function (timing guaranteed). * Tweak `GroupTestCase.createTestProcedures(...)` to support a custom duration/delay * GroupTests improvements to use the new `checkAfterDidExecute` function * Fix `ProcessProcedureTests.test__cancel_process_after_launched()` Requires guaranteed ordering (`cancel()` *must* be called after the ProcessProcedure didExecute). * Removes all Code Signing settings (#649) * [OPR-641]: Removes code signing identities * [OPR-641]: Moves ProcessProcedureTests.swift to the correct location * Resolves ProcedureKitCloud compilation issues with Xcode 8.2 beta 2 (#644) Xcode 8.2 beta 2 (8C30a) changed several of the CloudKitOperation property/block types slightly. Make these `associatedtype`s so they work on both Xcode 8.2 beta 2 and earlier versions of Xcode 8. * NetworkProcedure testing improvements (#646) * Improve TestableURLSessionTaskFactory thread-safety * Improve TestableNetworkReachability thread-safety * `Final` cleanup (#647) * Mark certain non-open properties/methods in Procedure as `final` * Mark certain non-open properties/methods in GroupProcedure as `final` * Mark certain non-open properties/methods in RepeatProcedure as `final` * Mark ExclusivityManager as `final` * Mark certain non-open properties/methods in ProcedureQueue.swift as `final` * Mark certain non-open properties/methods in Condition as `final` * Mark `Condition.execute()` as `final public` Also add comments. `Condition` subclasses should override `evaluate(procedure:,completion:)`. * Adds Condition cancellation tests (#650) * Add functionality to ProcedureKitTestCase * Add Condition cancellation tests * Removes the beta tag from the internal versioning (#655) * ProcedureKitError string conversion memory leak fix (Swift bug) (#661) (#660) Swift leaks memory when converting `ProcedureKitError` to a string unless it conforms to `CustomStringConvertible` and provides its own `var description: String { get }` implementation. (Affects at least: Swift 3.0.1 & Xcode 8.1) Symptoms: Malloc 48 byte leaks This workaround eliminates the leaks. * Improves TimeoutObserver (#662) * TimeoutObserver improvements - Utilize a new ProcedureTimeoutRegistrar to handle the lifetime of timeout timers. - When a Procedure finishes (or a timer fires), cancel all outstanding timers for that Procedure. (Thus, a TimeoutObserver with a long timeout will immediately deallocate its timers and associated timeout blocks when the Procedure finishes, instead of keeping the timers / timeout blocks in memory until the timeout passes.) - Eliminate impact on the main thread by executing the timer blocks on a private queue. * Commit missing line * Additional TimeoutObserver tests * Supports Repeatable types (#659) * [OPR-657]: Adds documentation for Repeat * [OPR-657]: Adds Repeatable protocol * [OPR-657]: Updates documentation * [OPR-657]: Adds some missing documentation * Breaking Change: cancel() no longer finishes a procedure * Procedure should not call finish() from cancel() It is up to subclasses to handle cancellation appropriately. The default behavior of calling finish() when cancel() is called can be problematic. * Clarifications to documentation * Handle cancellation in UserLocationProcedure and ReverseGeocodeProcedure Call finish() once the location updates / geocoder are stopped/cancelled. * Add failing test case for DelayProcedure * Tweaks to handling cancellation in DelayProcedure. DelayProcedure should finish() as soon as the timer is cancelled. * Fix DelayProcedure cancellation handling * Fix ReverseGeocodeProcedure/UserLocationProcedure cancellation handling * Update Network*Procedures - Handle cancellation changes. - Special case: hide the URLSessionTask’s cancellation error if the NetworkProcedure was cancelled. - Add comments. * Update ProcessProcedure - Handle cancellation changes. - Special case: hide the Process’s cancellation error if the ProcessProcedure was cancelled. - Add comments. * Add comments * Added more comments. * Fixes building using SwiftPM (#663) * [OPR-633]: Updates project for SwiftPM * [OPR-633]: Removes comments from Package.swift * [OPR-663]: Updates podspecs * [OPR-663]: Fixes ProcedureKitNetwork building in SwiftPM * [OPR-663]: Fixes ProcedureKitCloud for SwiftPM * [OPR-663]: Fixes ProcedureKitLocation for SwiftPM * [OPR-663]: Fixes ProcedureKitMac for SwiftPM * Improve Swift 3 URLError handling in Network*Procedure (#664) * Improve Swift3 URLError handling in NetworkDataProcedure * Improve Swift3 URLError handling in NetworkDownloadProcedure * Improve Swift3 URLError handling in NetworkUploadProcedure * Fixes code signing issue that prevented building release builds (#666) * Fixes typo in link to Dan's github profile (#669) * Procedure EventQueue (#668) * Stress Test tweaks * Improve NetworkObserver testing * StressTestCase: set queue qualityOfService to .userInteractive * Improve ProcedureKitTestCase - Allow for setting `procedure` or `queue` to `nil` before test tearDown. - Set the FinishingProcedure’s name to something descriptive. * Remove old MutualExclusivity tests (The newer, robust MutualExclusivity tests cover these cases and more.) * Procedure utilizes an internal EventQueue The core of Procedure now utilizes an internal EventQueue - a serial FIFO queue onto which all user “events” are dispatched - which results in major thread-safety, performance, and ease-of-use wins, and a reduction in framework overhead. Numerous additional tests are included, edge-case bugs are fixed, and code is simplified. * Add CancellableResultProcedure / CancellableBlockProcedure * Improve the BlockProcedureStressTests * Clean-up Delay.swift Now that Procedure utilizes an internal EventQueue, locks and complexity can be reduced. * Clean-up UserLocationProcedure, ReverseGeocodeProcedure Now that it always safe to call `finish()` from a DidCancel observer, complexity can be reduced. * Improve LogManager / Logger performance - Provide custom `init()` variants for `_Logger` to ensure that only a single LogManager lock acquisition is required. - Adjust `LoggerProtocol` to not query the LogManager (global) state on every call to `log(…)` (which was hurting performance even when logging was disabled). Instead, each Procedure will pick up the current global logging settings when it is instantiated, and can then be further customized. To adjust the settings for all Procedures, simply set the values on LogManager at program start. - Switch LogManager to using a single PThreadMutex lock instead of a Protector for each property for a performance win. * Clean-up NetworkDataProcedure No longer needs a lock for `execute()`+DidCancelObserver. * Clean-up NetworkDownloadProcedure No longer needs a lock for `execute()`+DidCancelObserver. * Clean-up NetworkUploadProcedure No longer needs a lock for `execute()`+DidCancelObserver. * Additional Stress Tests * swiftlint tweaks * ProcessProcedureTests tweak * Improve TestableLocationManager, fix Location tests * Minor clean-up and renaming * Minor clean-up and renaming * Minor clean-up * Minor clean-up and renaming * Renaming PendingEvents * Minor renaming * Minor clean-up and renaming * Minor clean-ups / formatting * Small tweaks and refactoring * Tweaks and refactoring * Rename futureExecute / futureFinish to pendingExecute / pendingFinish * Replace the old Protector with MutexProtector (renamed to: Protector) * Minor tweaks / reformatting * Minor tweaks / renaming * Update comments * Update comments * Additional tests * Test tweak * Minor tweak Resolves a Leak-detector false-positive. * TimeoutObserver documentation tweak (#673) * Limit RetryProcedure to Procedure subclasses (#677) * Limit RetryProcedure to Procedure subclasses * NetworkRecovery fix * Improve AuthorizedFor mutual exclusivity (#679) Previously, an `AuthorizedFor` condition ensured that the Procedure to which it was added was mutually exclusive with any other Procedures with the same `AuthorizedFor` condition (where the base `CapabilityProtocol` was the same). However, what is needed is for the `AuthorizeCapabilityProcedure` (produced by the `AuthorizedFor` condition, and which can trigger a prompt for the capability) to be mutually exclusive with other `AuthorizeCapabilityProcedure`s with the same base CapabilityProtocol. This change ensure that two Procedures do not try to prompt for the same authorization/permission concurrently - but that once they have acquired the authorization/permission, the Procedures may then execute concurrently (unless some other MutuallyExclusive condition or dependency prevents it). * Improves Conditions (#681) * Improve Conditions This encompasses a major refactor of Conditions in ProcedureKit, improving performance, fixing bugs, and adding new features (while also expanding test coverage and documentation). ### The highlights: - Conditions are no longer `Procedure` subclasses, and are lighter-weight. - Condition processing is faster, and supports short-circuit evaluation for considerable performance improvements. - MutualExclusivity is now evaluated post-dependencies and condition evaluation (i.e. immediately before execute), resolving numerous issues and edge cases. - Numerous bugs have been fixed. - Internal implementation details are no longer exposed to user code unexpectedly. - Added a new `CompoundCondition` (and `AndCondition` / `OrCondition`) to support logical “&&” and “||” operations on Conditions. * Additional Mutual Exclusivity test * swiftlint tweaks * CompoundCondition should filter duplicates * Updates SwiftLint rule sets (#689) * [OPR-689]…
danthorpe
added a commit
that referenced
this pull request
Oct 5, 2017
* Supports async executors (#363) * Fixes a finished log message (#365) The "Operation Did finish" log was using the opposite logic for error logging * Group's internal queue is non-public; exposes appropriate properties (#361) * Make GroupOperation's internal queue non-public, and expose appropriate properties on GroupOperation - Make GroupOperation.queue ~private~internal. (So it can be tested.) - Expose appropriate run-time editable properties of the GroupOperation’s queue as properties on GroupOperation. Specifically: - public var maxConcurrentOperationCount: Int - public var suspended: Bool - public var qualityOfService: NSQualityOfService - Add tests. * [OPR-361]: Support underlying queue in Group * GatedOperation cancels composed operation when gate is closed (#377) * [OPR-377]: Adds early exit with guard * [OPR-377]: Refactors GatedOperation execute * [OPR-377]: Fixes typo * Result Injection protocol improvements (#378) * [OPR-378]: Updates result injection APIs * [OPR-378]: Adds unit tests * [OPR-378]: Removes unnecessary weak self capture * Fixes dependency gets added twice if it's direct & indirect (#379) * [OPR-379]: Adds a failing unit test * [OPR-379]: Makes indirect dependencies unique set * Removes TaskOperation from non-macOS platforms (#382) * Removes AlertPresentation mutual exclusion (#383) * Adds IgnoredCondition (#385) * Filters out indirect dependencies which have already been added (#386) * Fixes issues with ignored condition (#390) This means that conditions which are ignored mean that the attached operation does not execute, but also does not finish with an error. It’s a nicer use case than GatedOperation. This works by checking the OperationResult for .Ignored and then only cancel() instead of cancelWithError(). Note that if the operation also has .Failed(errors) condition result, in addition to .Ignored then the operation will still not run but this time with errors (as expected). Note that if the operation also has .Satisfied condition result, in addition to .Ignored then the operation will not run, but without errors. * NoFailedDependenciesCondition supports ignoring cancelled operations (#397) Fixes #396. * [OPR-396]: NoFailedDependenciesCondition support ignoring cancels * [OPR-396]: Refactors initializer * [OPR-396]: Renames the condition * Ability to add configuration to the next (retried) CloudKitOperation (#395) * Adds CloudKitOperation.setPrepareForRetryHandler() * Adds BatchedCloudKitOperation.setPrepareForNextOperationHandler() * Clean-up * Updated new APIs, added documentation -Simpler, cleaner, better APIs. -Added documentation and examples for the new APIs. * Add documentation for BatchedCloudKitOperation. * Updates project header (#399) * [OPR-399]: Updates the header * [OPR-399]: Updates the README to point to the new URL for header * Updates guidelines (#400) * [OPR-400]: Updates copyright holders to “ProcedureKit” * [OPR-400]: Adds a code of conduct * [OPR-400]: Fixes a markdown formatting issue * [OPR-400]: Adds CONTRIBUTING guidelines * [OPR-400]: Moves CONTRIBUTING to .github directory * [OPR-400]: Removes an empty section * [OPR-400]: Adds instruction on adding verbose logs. * [OPR-400]: Updates CONTRIBUTING guideline * [OPR-400]: Updates README too * [OPR-400]: Fixes some typos * Creates ProcedureKit project (#401) * [OPR-401]: Sets up ProcedureKit project * [OPR-401]: Adds ProcedureKitMobile This will cover iOS & watchOS * [OPR-401]: Adds ProcedureKitTV * [OPR-401]: Fixes Runtime Search Paths * [OPR-401]: Adds StressTests * [OPR-401]: Adds ProcedureKitMac * [OPR-401]: Enables code coverage on all testable schemes * [OPR-401]: Adds ProcedureKitCloud * [OPR-401]: Changes to module imports * [OPR-401]: Changes Cloud to latest deployment versions * ProcedureKit CI - Stage 1 (#403) * [OPR-403]: Changes Stress Tests to only run as part of the ProcedureKitMac scheme * [OPR-403]: Changes Cloud minimum target versions * [OPR-403]: Adds tests to CI - ProcedureKit macOS * [OPR-403]: Fixes Operations mac tests * [OPR-403]: Fixes Operations tests 2 * [OPR-403]: Fixes Swift version to 2.2 * [OPR-403]: Moves common scripts around * [OPR-403]: Updates scripts * [OPR-403]: Changes to the Fastlane name for mac * [OPR-403]: Updates build dependencies * [OPR-403]: Sets the correct destination platform * [OPR-403]: Updates scan invocation * [OPR-403]: Updates Fastfile * [OPR-403]: Trying to use which to find bundle * [OPR-403]: Using quotes * [OPR-403]: Adds setup first * [OPR-403]: Putting the whole setup into quotes * [OPR-403]: Attempting to add multiple lines to the command * [OPR-403]: Puts it all on one line * [OPR-403]: Adds more ProcedureKit steps * [OPR-403]: Fixes error in Stress Tests build settings * [OPR-403]: Pipline Uploads * [OPR-403]: Fixes pipelines * [OPR-403]: Uses pipeline upload correctly * [OPR-403]: Fixes error in mobile tests * [OPR-403]: Adds watchOS * [OPR-403]: Removes automatic code signing * [OPR-403]: Comments out watchOS builds * [OPR-403]: Adds TV * [OPR-403]: Removes ad-hoc code signing * [OPR-403]: Fixes Operations iOS * [OPR-403]: Sets iPhone Developer automatic code signing * [OPR-403]: Updates buildkite agent tags for iOS Simulator * [OPR-403]: Sets the development team in xcargs * [OPR-403]: Enables automatic code signing without a team set * [OPR-403]: Fixes issues with code signing settings for TV * [OPR-403]: Removes the development team * [OPR-403]: Puts everything into a single pipeline * [OPR-403]: Cleans up the pipeline * [OPR-403]: Sets personal team for mobile unit tests * [OPR-403]: Updates the Fastlane lane names * [OPR-403]: Adds a copy frameworks build phase * [OPR-403]: Removes copy files phase * [OPR-403]: Comments out problematic build jobs * [OPR-403]: Removes Operations CI jobs * ProcedureKit CI - Stage 2 (#404) * Update CI dependencies (#409) * [OPR-409]: Updates dependencies and enables pipeline * [OPR-409]: Fixes YML * [OPR-409]: Fully specifies the destination Starting to really not like Fastlane * [OPR-409]: Switches to iOS 10 simulators. * [OR-409]: Sets the developer directory * [OPR-409]: Removes tvOS for Mobile framework * [OPR-409]: Reorders the jobs * Add base types to ProcedureKit (#405) * [OPR-405]: Creates Procedure * [OPR-405]: Sets the Swift version * [OPR-405]: Cleans project * [OPR-405]: Changes to destination * [OPR-405]: Stops using Fastlane for testing macOS * [OPR-405]: Adds initial files for ProcedureQueue * [OPR-405]: Defines ProcedureObserver * [OPR-405]: Adds the default implementation of ProcedureObserver * [OPR-405]: Adds the rest of the observer protocols * [OPR-405]: Adds @available annotations * [OPR-405]: Adds block based observers * [OPR-405]: Adds Protector / DispatchQueue extension * [OPR-405]: Further updates to observers API * [OPR-405]: Adds extension to Operation This is for addCompletionBlock - but will be used for more stuff when we get into dependencies * [OPR-405]: Fixes lint issues * [OPR-405]: Adds Procedure protocol with AbstractProcedure * [OPR-405]: Starts interfaces in AbstractProcedure for execute & finish * [OPR-405]: Adds state transition * [OPR-405]: Refactors Procedure to be protocol based. * [OPR-405]: Adds most of the cancellaton functionality * [OPR-405]: Adds main implementation With a few TODOs * [OPR-405]: Fixes available renames * [OPR-405]: Changes AbstractProcedure back to Procedure * [OPR-405]: Adds Testing framework With TestProcedure class * [OPR-405]: Adds basic API to ProcedureTestCase * [OPR-405]: Updates dependencies * [OPR-405]: Commenting out non mac unit tests Run CI on iOS Simulators is basically impossible on beta version of Xcode. * [OPR-405]: Adds finishing and cancellation tests * [OPR-405]: Adds some finishing tests * Adds Logging (#428) * [OPR-428]: Adds LogSeverity * [OPR-428]: Adds logger * [OPR-428]: Updates logging stuff * [OPR-428]: Adds logging tests * Group (#430) * [OPR-430]: Adds Group * [OPR-430]: Adds initializers to Group * [OPR-430]: Adds add child API to Group * [OPR-430]: Corrects spelling * [OPR-430]: Adds finishing APIs to Group * [OPR-430]: Adds extension of unavailable APIs * [OPR-430]: Adds GroupObserverProtocol * [OPR-430]: Adds error handling and recovery to Group * [OPR-430]: Improves group observers API * [OPR-430]: Adds first group test * [OPR-430]: Adds some basic tests for Group * [OPR-430]: Adds more unit test for Group * [OPR-430]: More tests for group * Adds User Intent (#439) * [OPR-439]: Adds UserIntent to Procedure * [OPR-439]: Adds userIntent to Group * Stress Tests Phase 1 (#442) * [OPR-442]: Adds StressTestCase and completion block stress tests * [OPR-442]: Uses StressLevel directly. * [OPR-442]: Refactors the test case names * [OPR-442]: Refactors to remove StressTestCase Instead the stress function can be added to the base ProcedureKitTestCase * [OPR-442]: Adds group cancel stress test * [OPR-422]: Refactors group stress tests These are currently failing * [OPR-422]: Refactors schemes, as stress tests are run as part of Mac tests * [OPR-442]: Updates Stress Tests batches Uses intermediate BatchProtocol, and exposes a measure API. * [OPR-422]: Changes the active developer directory * [OPR-422]: Adds group child finishing order stress test * [OPR-422]: Fixes incorrect pipeline step * [OPR-422]: Adds more stress tests for Procedure * [OPR-422]: Fixes TestError mistake * [OPR-422]: Changes to use didCancelBlockObserver Instead of didFinishBlockObserver - there might be a subtle bug here. * [OPR-422]: Disables some checks - have identified that there is definitely an error in finishing logic * [OPR-422]: Moves stress tests to their own scheme * [OPR-422]: Adds stress fastlane * [OPR-422]: Trying to see how to trigger stress tests * [OPR-422]: Removing - * [OPR-422]: Changes the trigger to ProcedureKit * [OPR-422]: Add the pipeline update step back * [OPR-422]: Fixes yml * [OPR-422]: More changes to pipeline template * [OPR-422]: Fixes the slug This is case sensitive! * [OPR-422]: Triggers a different pipeline stress tests * [OPR-422]: Adds commit message to stress test build * [OPR-422]: Modifies measure to be a little quicker * [OPR-422]: Updates baselines with Mac Pro * [OPR-422]: Fixes mistake with finishing from cancel * Fix issue with newlines in pipeline upload (#445) * [OPR-445]: Removes message from upload script * [OPR-422]: Puts the commit back * Initial work on Result Injection (#446) * Adds Dependencies & Conditions (#429) * [OPR-429]: Adds Condition protocol and class * [OPR-429]: Adds conditions to procedure and queue * [OPR-429]: Adds tests for Conditions Also adds XCTAssertProcedure functions to make verifying Procedure behaviour more consistent. * [OPR-429]: Adds remaining unit tests for conditions Still got Ignored Condition to add * [OPR-429]: Fixes some documentation * [OPR-429]: Performs the stress tests in the same build * [OPR-422]: Adds stress tests for conditions * [OPR-429]: Adds IgnoredCondition * ProcedureKitError (#437) * [OPR-437]: Regorganized the Core group * [OPR-437]: Refactors Errors into ProcedureKitError * Completes Result Injection API test coverage (#447) * [OPR-447]: Sorts out ResultInjection * [OPR-447]: Completes result injection tests * Fixes Xcode 8 GM issues (#463) * BlockProcedure (#450) * [OPR-450]: Adds BlockProcedure * [OPR-450]: Adds unit tests for map and block procedures * [OPR-450]: Adds some stress tests for block procedure * [OPR-450]: Updates stress tests * [OPR-450]: Fixes Xcode 8 GM escaping issue * [OPR-450]: Papers over some possible issues with finishing. In many cases the `should finish after cancelling` logic is returning false. * [OPR-450]: Removes some excessive logging * [OPR-450]: Adjusts variation to 15% * Mutual exclusive conditions (#448) * [OPR-448]: Adds MutualExclusion * [OPR-448]: Adds support for adding dependencies for mutual exclusion * [OPR-448]: WIP on mutual exclusivity * [OPR-448]: Finishes off test cases for mutual exclusivity * [OPR-448]: Refactors add condition API to attach condition I want to make the API consistent - but not choose consistency over intent. So, `add(dependency: myDependency)` makes sense - as it signals that the dependency is already managed by some other queue/system. Where as for a Condition, we specifically _attach_ it to Procedure instance, and it does not (ideally should not) be managed outside the Procedure. So, I want the concept of “attaching conditions to procedures” to be the language which is used to describe the behaviour. * DelayProcedure (#449) * [OPR-449]: Adds delay procedure * [OPR-449]: Adds DelayProcedure tests * Renames Group to GroupProcedure (#468) * Adds ProcedureKit.podspec (#467) * Adds NegatedCondition (#471) * Adds SilentCondition (#472) * Procedure finishing fixes (#474) * Resolve finishing issues related to FinishingFrom. * Add StressTest that covers concurrent calls to finish() * Revert ProcedureKitTestCase expectation fulfillment back to the main queue. * Adds BlockCondition (#473) * Adds NoFailedDependenciesCondition (#470) * Adds TimeoutObserver (#475) * [OPR-475]: Adds TimeoutObserver * [OPR-475]: Fixes issues with TestProcedure It was not correctly delaying. * Procedure name and identity (#478) * [OPR-478]: Adds name and Identity * [OPR-478]: Fixes some failing tests * [OPR-478]: Fixes another failing name test * Adds BlockObserver (#480) * [OPR-480]: Adds BlockObserver * [OPR-480]: Tweaks to stress tests * Adds ComposedProcedure & GatedProcedure (#487) * RepeatProcedure (#488) * [OPR-488]: Initial work on RepeatProcedure * [OPR-488]: Adds remaining test coverage * RetryProcedure (#491) * [OPR-491]: Adds RetryProcedure * [OPR-491]: Unifies the generic init pattern for repeat and retry procedures * Adds support for Capabilities (#492) * [OPR-492]: Fixes incorrectly spelt protocol * [OPR-492]: Adds Capability Including CapabilityProtocol, GetAuthorizationStatus, Authorize, AuthorizedFor * Adds BackgroundObserver (#476) * [OPR-476]: Fixes stress tests * [OPR-476]: Adds BackgroundObserver * [OPR-476]: Gets the Mobile test suite working * [OPR-476]: Switches code coverage on * [OPR-476]: Adds missing callback This was causing a failing unit test * [OPR-476]: Removes unnecessary build phase * [OPR-476]: Finishes BackgroundObserver tests * [OPR-476]: Removes verbose logging in test case * Adds FilterProcedure (#496) * [OPR-496]: Adds FilterProcedure * [OPR-496]: Adds filter method for when Result is a sequence * Adds ReduceProcedure (#497) * [OPR-497]: Adds ReduceProcedure * [OPR-497]: Refactors Map, Filter adds FlatMap MapProcedure is really a TransformProcedure. MapProcedure and FilterProcedure are now simple subclasses of ReduceProcedure, along with FlatMapProcedure. * Adds NetworkObserver (#498) * [OPR-498]: Adds NetworkObserver Additionally, this updated ProcedureKitTestCase to automatically add async expectation fulfills around operations which might be produced by a procedure. * [OPR-498]: Refactors ProcedureKitTestCase slightly for Swift 3 conventions. * Adds Location.Capability (#499) * [OPR-499]: Adds ProcedureKitLocation framework * [OPR-499]: Supports sychronous dispatch onto the main queue This is safe to call if already on the main queue. * [OPR-499]: Adds Capability.Location * Adds UserLocationProcedure (#500) * [OPR-500]: Adds UserLocationProcedure * [OPR-500]: Removes unneeded error struct * [OPR-500]: Fixes issue with tvOS * Corrects minimum deployment targets (#503) Fixes #501 * [OPR-501]: Fixes issues with deployment versions * [OPR-501]: Setting tvOS to 9.2 * Adds ReverseGeocodeProcedure (#502) * [OPR-502]: Adds ReverseGeocodeProcedure * [OPR-502]: Adds ProcedureKitMobile as a build dependency * [OPR-502]: Fixes a mistake where macOS location tests were requiring iOS simulator * [OPR-502]: Uses gym to ensure iOS builds ProcedureKitMobile before testing Location * [OPR-502]: Use scan instead of gym This is a hack. I want to make sure that when we test ProcedureKitLocation on iOS we have build ProcedureKitMobile. * Adds ReverseGeocodeUserLocationProcedure (#504) * [OPR-504]: Adds/renames files * [OPR-504]: Adds ReverseGeocodeUserLocationProcedure * [OPR-504]: Rounds out the unit tests on ReverseGeocodeUserLocationProcedure * Makes procedures open where appropriate (#510) * Refactors BlockProcedure (#511) * Adds AnyProcedure (#516) * [OPR-516]: Removes import foundation This is done by the prefix header * [OPR-516]: Adds AnyProcedure * [OPR-516]: Uses the correct underlying queue throughout AnyProcedure * Fixes regression of failing release build (#518) * Renames AuthorizationStatusProtocol to AuthorizationStatus (#519) * Renames capability reated procedures (#520) * Renames attach(condition: Condition) to add (#521) * Adds Capability.CloudKit (#523) * [OPR-523]: Adds Capability.CloudKit * [OPR-523]: Enables CI builds for CloudKit stuff on iOS and tvOS * Adds ProcedureKitNetwork framework (#524) * [OPR-524]: Adds ProcedureKitNetwork framework * [OPR-524]: Adds Network to CI jobs * [OPR-524]: Renames Stress Tests job * [OPR-524]: Shares the network scheme * [OPR-524]: Imports Foundation instead of Cocoa * [OPR-524]: Forces Stress Tests onto a non-simulator agent * Adds NetworkDataProcedure (#525) * [OPR-525]: Adds NetworkDataProcedure * [OPR-525]: Fixes up some unit tests * [OPR-525]: Adds missing test coverage * Moves TestableNetwork into TestingProcedureKit framework (#526) * Refactors injectDependency API to be an extension on ProcedureProtocol instead. (#527) * Adds transform block result injection API (#528) * [OPR-528]: Refactors result injection Uses an intermediatory injectResult(from: via:) API, which allows the caller to provide a throwing block to transform the result into the requirement. * [OPR-528]: Removes unneeded return * [OPR-528]: Fixes error in ProcedureKitLocation * Adds default empty implementations some queue delegate methods (#531) Only added the will-do-something ones. Fixes #530 * Adds space in the repo for presentations (#533) * [OPR-533]: Adds CocoaHeads Stockholm talk Contact @danthorpe if you want the original Keynote file. * [OPR-533]: Adds Sky-UK iOS Community Talk * [OPR-533]: Adds a presentations README * Disables the log for AnyProcedure (#534) * Fixes bug where GroupProcedure collects errors from children after its been cancelled (#532) * [OPR-532]: Adds failing test * [OPR-532]: Checks cancelled state of the group We can exit this delegate callback early if the group has already been cancelled. * [OPR-532]: Removes default implementation of willFinish It seems that adding default implementations here causes some odd behaviour / intermittent crash where this is overwritten in the QueueDelegate. * [OPR-532]: Fixes a unit test which is now mis-counting errors. * Adds .then { } API (#536) * [OPR-176]: Adds then extension on Operation * [OPR-176]: Implements .then { } API * [OPR-176]: Adds enqueue method to a collection of Operations * [OPR-176]: Fixes header docs * Removes default argument for session in NetworkDataProcedure (#538) * Tweaks the cancel block procedure stress tests (#539) There might be an underlying issue. As normally a batch of 10_000 finishing in ~ 5 seconds. But sometimes fails because it times out, meaning that an expectation is not getting fulfilled. * Moves ProcedureKit imports to umbrella headers (#540) * [OPR-540]: Putting the appropriate imports into umbrella headers * [OPR-540]: Fixing issues with importing ProcedureKit into TestingProcedureKit * Updates ProcedureKit podspec with subspecs (#508) * [OPR-508]: Lints podspec without an warnings or errors. * [OPR-508]: Fixes errors running tests * Adds ResilientNetworkProcedure (#537) * [OPR-537] Adds ResilientNetworkProcedure * [OPR-537]: Updates retry request with error code * [OPR-537]: Adds edge case for ResilientNetworkProcedure In some situations, the HTTP status code might well require (depending on the behaviour) a retry. * [OPR-537]: Fixes simple unit tests * Refactor ResultInjection to use PendingValue enum (#541) * [OPR-541]: Refactors ResultInjectionProtocol to use PendingValue enum * [OPR-541]: Renames ResultInjectionProtocol to ResultInjection * Fixes BlockProcedure stress tests (#544) * [OPR-544]: Fix test__cancel_block_procedure() failures It was possible for the testing BlockProcedure to finish prior to the `block.cancel()` call, which would result in some of the BlockProcedures never cancelling (as they had finished first), and a failing test. Fixed by using a semaphore inside the BlockProcedure’s block. Additionally, the test now waits for all BlockProcedures to cancel *and* finish. * [OPR-544]: Added a new stress test for BlockProcedure cancelling & finishing behavior (allowing for possible races between cancelling and finishing) * Fixes ExclusivityManager synchronization bug (#545) Fixes #543 The ExclusivityManager was using `DispatchQueue.initiated`, which returns a global **concurrent** queue, however its internals are dependent upon **serial** execution of add/remove. Modified to use a serial queue. * Adds ResultProcedure and overloads injectResult(from:) (#546) * Adds HTTPResult<Payload> (#547) * Fix test crashes caused by QueueTestDelegate (#549) QueueTestDelegate was not thread-safe. This could result in crashes running random tests. Fixed by making QueueTestDelegate’s methods thread-safe. * Adds ProcedureKitTestCase wait function that takes an array (#552) * Adds TestingProcedureKit podspec (#553) * Adds Mutual Exclusivity concurrency testing (#550) * Add ConcurrencyTestCase Exposes functionality to test operation concurrency. * Add Mutual Exclusivity concurrency tests * Refactored ConcurrencyTestCase * Refactored ConcurrencyTestCase * Adds didExecuteObserver (#554) * [OPR-554]: Adds code with failing test * [OPR-554]: Calls didExecuteObservers * [OPR-554]: Fixes a typo * [OPR-554]: Adds some documentation to the DidExecuteObserver * Fixes mistake in Fastfile (#557) * [OPR-557]: Fixes error in Fastfile * [OPR-557]: Removes duplicate scan I remember now, as part of location, we used to build Mobile too - because there was a dependency on iOS. But this has since been removed. * Fixes release configuration issues with Xcode 8.1 (#559) Fixes #548 * [OPR-548]: Fixes issue with Xcode 8.1 release configuration * [OPR-548]: Fixes some SwiftLint warnings. * [OPR-548]: Fixes Xcode project warnings in Xcode 8.1 * Adds GroupProcedure concurrency tests (#556) * Add GroupConcurrencyTestCase * Add GroupProcedure.maxConcurrentOperationCount tests * Fixes registrar typo (#562) * Adds NetworkDownloadProcedure. (#565) The implementation for class and test is largely inspired by `NetworkDataProcedure` class. * Adds NetworkUploadProcedure. (#567) * Add NetworkUploadProcedure. The implementation class and test has been largely inspired by `NetworkDataProcedure`. The requirement type is currently a pending value of a tuple. Maybe would it make more sense to create a dedicated struct to add more clarity in the case of dependencies injection ? * Use an `HTTPRequirement` struct for requirement. As discussed, an `HTTPRequirement` struct is used instead of a tuple. * Fixes Condition to support ResultInjection (#566) * [OPR-566]: Replaces Condition result with PendingValue<ConditionResult> * [OPR-566]: Refactors how conditions are evaluated This fixes a existing issue where the ConditionEvaluation enum was basically just like ConditonResult, except that it could hold an array of errors. This has been resolved by using an internal error type `ProcedureKitError.FailedConditions` to collect multiple errors from failed conditons, so that we can reduce a sequence of `ConditionResult`s into a single one. * [OPR-566]: Explicitly adds a Result typealias * [OPR-566]: Fixes error where cancelled conditions would throw a fatal error. * [OPR-566]: Removes verbose log * Adds ProcessProcedure. (#570) * Add ProcessProcedure. The class has been largely inspired by the original `TaskOperation`. Refers to #568. * Apply requested changes. Correctly implement `Equatable` for sub-error enum. Use camel case for the enum. Fix closure self semantics. * Calls TestableReverseGeocoder completionHandler on the main queue (#572) * Improves performance of adding observers * Procedure.add(observer:) performance tweak Append directly to the protected observers array. * Fix swiftlint `variable_name` warning * Makes ProcedureQueue.add(operation: Operation) method open (#578) * Fixes NetworkObserver thread-safety (#576) (#577) * Fix NetworkObserver thread-safety By fixing NetworkActivityController `start()`/`stop()` thread-safety. (And making private methods/variables private.) * NetworkObserver test fixes * Reduce test delay * Additional GroupProcedure tests (#579) * Adds CloudKitProcedure (#542) * [OPR-542]: Adds shell of CloudKit files * [OPR-542]: Adds extensions for CKOperation * [OPR-542]: Adds extensions for CKDatabaseOperation * [OPR-542]: Adds extensions for CKAcceptSharesOperation * [OPR-542]: Adds extensions for CKDiscoverAllContactsOperation * [OPR-542]: Adds extensions for CKDiscoverAllUserIdentifiesOperation * [OPR-542]: Adds extensions for CKDiscoverUserIdentitiesOperation * [OPR-542]: Adds extensions for CKDiscoverUserInfosOperation * [OPR-542]: Adds extensions for CKFetchDatabaseChanges * [OPR-542]: Adds extensions for CKFetchDatabaseChangesOperation * [OPR-542]: Adds extensions for CKFetchRecordChangesOperation * [OPR-542]: Moves the interface into the extension files * [OPR-542]: Fixes dispatchQueue * [OPR-542]: Adds extensions to CKFetchRecordsOperation * [OPR-542]: Adds extensions for CKFetchRecordZoneChangesOperation * [OPR-542]: Removes unnecessary public properties * [OPR-542]: Adds extensions for CKFetchRecordZonesOperation * [OPR-542]: Adds extensions for CKFetchShareMetadataOperation * [OPR-542]: Adds extensions for CKFetchShareParticipantsOperation * [OPR-542]: Adds extensions for CKFetchSubscriptionsOperation * [OPR-542]: Adds extensions for CKMarkNotificationsReadOperation * [OPR-542]: Adds extensions for CKModifyBadgeOperation * [OPR-542]: Adds extensions for CKModifyRecordsOperation * [OPR-542]: Adds extensions for CKModifyRecordZonesOperation * [OPR-542]: Adds extensions for CKModifySubscriptionsOperation * [OPR-542]: Adds extensions for CKQueryOperation * [OPR-542]: Adds missing APIs for error handlers * [OPR-542]: Adds testable CK operation classes * [OPR-542]: Adds tests for CKOperation, CKDatabaseOperation and CKAcceptSharesOperation * [OPR-542]: Removes missing test cases from tvOS * Small typo fix * Adds tests for CKDiscoverAllContactsOperation * Adds tests for CKDiscoverAllUserIdentitiesOperation * Adds tests for CKDiscoverUserIdentitiesOperation * Adds tests for CKDiscoverUserInfosOperation * [OPR-542]: Adds tests for CKFetchAllChanges protocol * [OPR-542]: Adds tests for CKFetchDatabaseChangesOperation * [OPR-542]: Adds tests for CKFetchNotificationChangesOperation * [OPR-542]: Adds tests for CKFetchRecordChangesOperation * [OPR-542]: Adds tests for CKFetchRecordsOperation * [OPR-542]: Added missing `recordZoneFetchCompletionBlock` for CKFetchRecordZoneChangesOperationProtocol extensions * [OPR-542]: Adds tests for CKFetchRecordZoneChangesOperation * [OPR-542]: Adds tests for CKFetchRecordZonesOperation * [OPR-542]: Adds tests for CKFetchShareMetadataOperation * [OPR-542]: Adds tests for CKFetchShareParticipantsOperation * [OPR-542]: Adds tests for CKFetchSubscriptionsOperation * [OPR-542]: Minor typo fix To follow the original API naming, change `setMarkNotificationReadCompletionBlock` to `setMarkNotificationsReadCompletionBlock`. * [OPR-542]: Adds tests for CKMarkNotificationsReadOperation * [OPR-542]: Adds tests for CKModifyBadgeOperation * [OPR-542]: Adds tests for CKModifyRecordsOperation * [OPR-542]: Adds tests for CKModifyRecordZonesOperation * [OPR-542]: Adds tests for CKModifySubscriptionsOperation * [OPR-542]: Adds tests for CKQueryOperation * [OPR-542]: Fixes whitespace in test cases * [OPR-542]: Adds CloudKitProcedure<CKAcceptSharesOperation> tests * [OPR-542]: Fixes tests on tvOS. Again. * [OPR-542]: Adds tests for CKDiscoverAllContactsOperation * [OPR-542]: Adds tests for CKDiscoverAllUserIdentitiesOperation * [OPR-542]: Adds tests for CKDiscoverUserIdentitiesOperation * [OPR-542]: Adds tests for CKDiscoverUserInfosOperations * [OPR-542]: Adds tests for CKFetchDatabaseChangesOperation * [OPR-542]: Unifies testing of common properites * [OPR-542]: Adds tests for CKFetchNotificationChangesOperation * [OPR-542]: Adds tests for CKFetchRecordChangesOperation * [OPR-542]: Adds test for CKFetchRecordsOperation * [OPR-542]: Adds tests for CKFetchRecordZoneChangesOperation * [OPR-542]: Adds test for CKFetchRecordZonesOperation * [OPR-542]: Adds tests for CKFetchShareMetadataOperation * [OPR-542]: Adds tests for CKFetchShareParticipantsOperation * [OPR-542]: Fixes inconsistently named tests * [OPR-542]: Adds tests for CKFetchSubscriptionsOperation * [OPR-542]: Adds tests for CKMarkNotificationsReadOperation * [OPR-542]: Adds tests for CKModifyBadgeOperation * [OPR-542]: Adds tests for CKModifyRecordsOperation * [OPR-542]: Adds tests for CKModifyRecordZonesOperation * [OPR-542]: Adds test for CKModifySubscriptionsOperation * [OPR-542]: Adds test for CKQueryOperation * [OPR-542]: Adds tests which trigger default retry behavior * [OPR-542]: Adds tests for set/get all errors handlers * [OPR-542]: Adds tests for custom error handlers * Adds Profiler (#573) * Implement Profiler as specified in #569. The implmentation is largely inspired by the original `Profiler.swift` file. * Add first set of tests. The test has been largely inspired by the original tests classes. I have a commented test taht fails. After trying to debug for a while, I suspect maybe an issue inside GroupProcedure or the original implementation. * Apply requested changes. Perform changes as requested. * Adds public initialiser to HTTPRequirement (#586) Declaring a constructor for the `HTTPRequirement` allows the construction of the struct without any issue. * Removes GroupProcedureObserver protocol (#583) Instead ProcedureObserver takes over this responsibility. * [OPR-574]: Cleans up white space & style for consistency * [OPR-574]: Uncomments failing test * [OPR-574]: Adds new API to ProcedureObserver protocol * [OPR-574]: Removes temporary print statements * [OPR-574]: Refactors to support willAdd & didAdd observer callbacks. * [OPR-574]: Removes commented out line. * [OPR-574]: Removes group observers. * [OPR-574]: Removes extraneous logging in some tests * [OPR-574]: Makes add(observer:) open for overriding * [OPR-574]: Adds some documentation comments to public interfaces * Supports Arbitrary mutual exclusion category names (#587) Fixes #580. * [OPR-580]: Supports arbitrary mutual exclusion category names * [OPR-580]: Fixes default category for AuthorizedFor * Adds NetworkReachableProcedure (#563) * [OPR-563]: Adds Reachability functionality * [OPR-563]: Adds additional files for testing support * [OPR-563]: Adds tests for Reachability * [OPR-563]: Adds basis of NetworkReachableProcedure * [OPR-563]: Adds simple network reachability procedure tests * [OPR-563]: Fixes issue with Protector write being synchronous. * [OPR-563]: Refactors DeviceReachability slightly * [OPR-563]: Changes Protector behavior back to be non-blocking * [OPR-563]: Fixes Reachability.Device * [OPR-563]: Adds NetworkProcedure and ProcedureKitNetworkError * [OPR-563]: Fixes for network error tests * [OPR-563]: Adds remaining tests for Reachable procedure * [OPR-563]: Removes unnecessary logging * Refactors produce API (#588) * Add failing test * Test tweaks * Changes to Procedure.produce(operation:) handling Fixes failing test case, and simplifies execution flow. Changes `willEnqueue()` to `willEnqueue(on: ProcedureQueue)`. `func produce(operation: Operation)` now throws. * Ported additional test case from Operations 3.x. * swiftlint tweak * Fixed mobile tests. * Adds missing equality cases for ProcedureKitError.Context (#591) Fixes #589 * Supports merging collections of ResultInjection Procedures (#593) * [OPR-593]: Adds gather and reduce APIs * [OPR-593]: Removes the rethrows While the nextPartialResult closure can throw, this error is not re-thrown. Instead, because this block is executed after the receiver’s procedures have all finished, the error means that the `ResultProcedure` will finish with an error. * [OPR-593]: Adds test case for throwing closure * [OPR-593]: Refactors gather() so that it is a specialization of new flatMap API * Improves how stress tests are run in CI (#594) * [OPR-594]: Updates pipeline queues * [OPR-594]: Fixes yaml * [OPR-594]: Disables Thread Sanitizer for Stress Tests * [OPR-594]: Uses Release configuration for stress tests * Fix StressTestCase Batch counters thread-safety (#555) (#596) * Fixes public access levels for CKProcedure (#599) * Fixes some RepeatProcedure thread-safety issues (#597) Fix issues identified by an audit and Thread Sanitizer * Fixes Procedure & Support thread-safety (#598) * Change Protector.write() to be synchronous (and optionally return a value from the block) Thread Sanitizer identified a data race caused by the combination of the prior asynchronous `write()` and deinitialization. * Explicitly `import Dispatch` in Support.swift Fixes an occasional Xcode warning display glitch. * Fix Protector.read() to no longer require an `escaping` block * Adds back `Protector.write(_:completion:)` Although, like the new write(_:) method, this is now synchronous. * Wrap all properties of Procedure in a Protector to ensure thread-safety `errors`, `observers`, `directDependencies`, `conditions` (and associated methods) are now thread-safe * Fix comment formatting * Removes @testable import (#600) Exposes NSLock and NSRecursiveLock extensions * Add RepeatProcedure cancellation stress test (#602) * Adds more GroupProcedure test coverage (#603) * Additional / improved GroupProcedure test cases * Remove unused private setter * Refactors of Result Injection APIs (#601) * [OPR-601]: Renamed PendingResult to PendingProfileResult * [OPR-601]: Adds protocols for Input & Output * [OPR-601]: Refactors for InputProcedure & OutputProcedure * [OPR-601]: Refactors ReduceProcedure as a TransformProcedure subclass * [OPR-601]: Refactoring for InputProcedure & OutputProcedure * [OPR-601]: Refactoring Condition to use Result<Bool> * [OPR-601]: Refactors ProcedureKitNetwork result injection * [OPR-601]: Refactors Location for result injection * [OPR-601]: Removes ResultInjection.swift * [OPR-601]: Removes left over properties * [OPR-601]: Tidies up ResultProcedure & TransformProcedure * [OPR-601]: Adds finish(withResult:) API * [OPR-601]: Refactors to use finish(withResult:) * [OPR-601]: Renames HTTPRequirement & HTTPResult * Renames Result to ProcedureResult (#605) * [OPR-605]: Renames Result to ProcedureResult Just to help with any interop issues with antitypical/Result * [OPR-605]: Renames Result to ProcedureResult * Adds AsyncBlockProcedure (#606) * [OPR-606]: Adds AsyncBlockProcedure As a specialization of AsyncResultProcedure * [OPR-606]: Moves async block tests into same file * [OPR-606]: Adds AsyncTransformProcedure * Adds @escaping marker to the FinishingBlock (#607) * Fixes NetworkActivityController internal timer (#608) * NetworkActivityController's delayed hide should occur on the queue Fixes data race. * Remove outdated test * NetworkDataProcedure, NetworkDownloadProcedure, NetworkUploadProcedure thread-safety (#609) * Adds NetworkProcedure (#561) * [OPR-561]: Refactoring ResilientNetworkProcedure - Supports request timeout - Adds HTTPStatusCode where we only even consider retrying client or server errors. - Adds some initial tests * [OPR-561]: Refactors NetworkResilience * [OPR-561]: Refactor to unify reachable & resilience network procedures * [OPR-561]: Adds resilience error handling support This is so that even if the network request “succeeds” but results in say, a server error, we will still trigger retries. * [OPR-561]: Fixes typos * Add missing imports to make Xcode happier (#611) * Add explicit imports to the top of ProcedureKit files This makes Xcode happier. * Add missing imports to the top of ProcedureKitCloud files This makes Xcode happier. * Add missing imports to the top of ProcedureKitMobile files This makes Xcode happier. * Add missing imports to the top of ProcedureKitLocation files This makes Xcode happier. * Fixes BackgroundObserver data race (#614) * Makes NetworkObserver cross-platform (#613) * NetworkObserver and NetworkActivityController cross-platform work On all platforms, the following initializers are available: `NetworkObserver.init(controller: NetworkActivityController)` `NetworkActivityController.init(timerInterval: TimeInterval = 1.0, indicator: NetworkActivityIndicatorProtocol)` To implement your own network activity indicator display, conform to `NetworkActivityIndicatorProtocol`. NetworkActivityController ensures that all accesses of the indicator’s `networkActivityIndicatorVisible` property are serialized on the main queue. On iOS (but *not* in application extensions), the following convenience initializers are available that utilize `UIApplication.shared` to display/hide the network activity indicator in the status bar: `NetworkObserver.init()` `NetworkActivityController.init(timerInterval: TimeInterval = 1.0)` `NetworkActivityController.shared` * [OPR-612]: Moves NetworkObserver into Network framework * [OPR-612]: Moves NetworkObserver into ProcedureKit Keeps iOS non-extension related elements in ProcedureKitMobile * Add documentation * Fixes BackgroundObserver on iOS 8.x (#615) To support iOS < 9.0 and macOS < 10.11, NotificationCenter observers **must** be properly removed, or a crash may result. * Fixes DelayProcedure thread-safety (#616) * Fixes to Location related procedures (#619) * Capability.Location should set its registrar's delegate to nil on deinit. CLLocationManager’s delegate is `unowned(unsafe)`, and we must ensure it is set to nil before the object goes away. The only strong reference to the delegate that Capability.Location sets is stored within Capability.Location. * LocationCapabilityTests tweaks Explicitly set the test CLLocationManager’s `delegate` back to nil. Explicitly wait on `capability.requestAuthorization` to fulfill an expectation. * ReverseGeocodeProcedureTests tweaks * Fix an occasional crash running the Location tests It seems there may be an edge case in CoreLocation triggered when creating (and releasing) lots of CLLocationManager instances (as previously happened when each test, using its own TestableLocationServicesRegistrar, created a “fake” CLLocationManager). Change `TestableLocationServicesRegistrar`’s “fake” CLLocationManager (which is only used to populate a parameter in the delegate callbacks) to a static class variable. * Compiles out SystemConfiguration related stuff from watchOS (#621) * Adds an All subspec (#623) * Adds missing imports in TestingProcedureKit (#625) Noticed this issue after doing some integration testing via CocoaPods * Network*Procedure tweaks (#626) * Resolve cancellation race condition in Network*Procedure Must check `!isCancelled` inside the `stateLock`, or it is possible for a `NetworkDataProcedure`/`NetworkDownloadProcedure`/`NetworkUploadProcedur e` that is cancelled after the `execute()` function is called, but before the acquisition of the `stateLock` inside it, to continue to create a network task. * Mark `task` as `private(set)` The `task` variable should not be set outside of the `NetworkDataProcedure` / `NetworkDownloadProcedure` / `NetworkUploadProcedure`. * Memory leaks fixes highlighted by Visual Memory Debugger (#624) * TimeoutObserver should capture a weak reference to the procedure * RetryIterator should not maintain a strong reference to the RetryProcedure RetryIterator’s RetryFailureInfo (`info`) property is set right before `addNextOperation()` is called, which calls `next()` on the RetryIterator (which then uses the RetryFailureInfo). Ultimately, the RetryFailureInfo contains strong references to the RetryProcedure. And since the RetryProcedure owns the RetryIterator, which owns the RetryFailureInfo… We end up with a reference cycle. As an immediate quick fix, since the RetryFailureInfo is only used in the call to `addNextOperation()`, set it back to `.none` after the call. * Add test to catch reference cycles in RetryProcedure (Fixed by prior commit.) * GroupProcedure: ensure that internal queue is emptied on deinit Previously, a GroupProcedure that was created and released but never added to a queue would leak the child operations on its internal OperationQueue. To ensure that it is safe to release a GroupProcedure in all circumstances, add a `deinit` handler that explicitly cancels all operations on the queue, and also ensures that the queue is not suspended (so the queue will handle the clean-up). * Revert "GroupProcedure: ensure that internal queue is emptied on deinit" This reverts commit f2b7176fc8a96e841c8829f8d3b903633c50e883. * GroupProcedure: ensure that internal queue is emptied on deinit Previously, a GroupProcedure that was created and released but never added to a queue would leak the child operations on its internal OperationQueue. To ensure that it is safe to release a GroupProcedure in all circumstances, add a `deinit` handler that explicitly cancels all operations on the queue, and also ensures that the queue is not suspended (so the queue will handle the clean-up). * Procedure: Use an autoreleasepool in `start()` override Replicate the `NSOperation.start()` autorelease behavior by pushing an autoreleasepool before calling `main()`, and popping after `main()` returns. This is particularly important because we override the default `start()` and `main()` behavior, and our `main()` calls the Procedure subclass’s `execute()` (and we need to ensure that `execute()`, which is running on a background thread, has an autoreleasepool). * Resolves cancellation race condition in Network*Procedure (#627) The internal cancel observer should be a DidCancelObserver. * Adds step to CI for CocoaPod integration (#630) * [OPR-630]: Adds TryProcedureKit trigger * [OPR-630]: Sets the correct commit * [OPR-630]: Lowercase pipeline name * [OPR-630]: Fixes a pipeline typo * [OPR-630]: Renames cocoapods branch in TryProcedureKit * Fixes copy/paste typos (#634) Fixes #633. * Supports result injection in NetworkProcedure (#632) Closes #631. * [OPR-32]: Makes NetworkProcedure conform to OutputProcedure * [OPR-632]: Adds convenience API for injecting payload from network * [OPR-632]: Adds tests for injectPayload(fromNetwork:) * Removes the fatal override of waitUntilFinished() (#635) * Adds UIProcedure & AlertProcedure (#592) UIProcedure & AlertProcedure * ProcessProcedure improvements & thread-safety (#639) * Move ProcessProcedureTests to the "Mac Tests" group * ProcessProcedure thread-safety `NSTask`/`Process` is listed as a Thread-Unsafe Class in the Foundation Framework Thread Safety guide. As such, some major modifications to ProcessProcedure were necessitated. - `init(…)` now takes all the possible configuration parameters for the Process, instead of a Process instance (the only required parameter is `launchPath`) - the ProcessProcedure is now responsible for creating the Process object and managing it - there is no public accessor for the Process object (it’s now an internal implementation detail of ProcessProcedure) - various additional methods / properties were added to expose Process object functionality directly on the ProcessProcedure * Lots of ProcessProcedure tests * Minor tweak * Added more (read-only) properties * Added more tests * Add missing import * [OPR-639]: Very minor tweaks * NetworkProcedure cancellation testing enhancements (#640) * Enhance TestableURLSessionTask and TestableURLSessionTaskFactory cancellation support The behavior now better replicates NSURLSession/NSURLSessionTask behavior on cancellation, including providing the proper error to the completionHandler. * More cancellation tests for NetworkDataProcedure * More cancellation tests for NetworkDownloadProcedure * More cancellation tests for NetworkUploadProcedure * Minor tweak * Minor tweak * Testing after DidExecute improvements/fixes (#643) * Add `checkAfterDidExecute` method to ProcedureKitTestCase Supports executing a block after a procedure has finished running its `execute()` function (timing guaranteed). * Tweak `GroupTestCase.createTestProcedures(...)` to support a custom duration/delay * GroupTests improvements to use the new `checkAfterDidExecute` function * Fix `ProcessProcedureTests.test__cancel_process_after_launched()` Requires guaranteed ordering (`cancel()` *must* be called after the ProcessProcedure didExecute). * Removes all Code Signing settings (#649) * [OPR-641]: Removes code signing identities * [OPR-641]: Moves ProcessProcedureTests.swift to the correct location * Resolves ProcedureKitCloud compilation issues with Xcode 8.2 beta 2 (#644) Xcode 8.2 beta 2 (8C30a) changed several of the CloudKitOperation property/block types slightly. Make these `associatedtype`s so they work on both Xcode 8.2 beta 2 and earlier versions of Xcode 8. * NetworkProcedure testing improvements (#646) * Improve TestableURLSessionTaskFactory thread-safety * Improve TestableNetworkReachability thread-safety * `Final` cleanup (#647) * Mark certain non-open properties/methods in Procedure as `final` * Mark certain non-open properties/methods in GroupProcedure as `final` * Mark certain non-open properties/methods in RepeatProcedure as `final` * Mark ExclusivityManager as `final` * Mark certain non-open properties/methods in ProcedureQueue.swift as `final` * Mark certain non-open properties/methods in Condition as `final` * Mark `Condition.execute()` as `final public` Also add comments. `Condition` subclasses should override `evaluate(procedure:,completion:)`. * Adds Condition cancellation tests (#650) * Add functionality to ProcedureKitTestCase * Add Condition cancellation tests * Removes the beta tag from the internal versioning (#655) * ProcedureKitError string conversion memory leak fix (Swift bug) (#661) (#660) Swift leaks memory when converting `ProcedureKitError` to a string unless it conforms to `CustomStringConvertible` and provides its own `var description: String { get }` implementation. (Affects at least: Swift 3.0.1 & Xcode 8.1) Symptoms: Malloc 48 byte leaks This workaround eliminates the leaks. * Improves TimeoutObserver (#662) * TimeoutObserver improvements - Utilize a new ProcedureTimeoutRegistrar to handle the lifetime of timeout timers. - When a Procedure finishes (or a timer fires), cancel all outstanding timers for that Procedure. (Thus, a TimeoutObserver with a long timeout will immediately deallocate its timers and associated timeout blocks when the Procedure finishes, instead of keeping the timers / timeout blocks in memory until the timeout passes.) - Eliminate impact on the main thread by executing the timer blocks on a private queue. * Commit missing line * Additional TimeoutObserver tests * Supports Repeatable types (#659) * [OPR-657]: Adds documentation for Repeat * [OPR-657]: Adds Repeatable protocol * [OPR-657]: Updates documentation * [OPR-657]: Adds some missing documentation * Breaking Change: cancel() no longer finishes a procedure * Procedure should not call finish() from cancel() It is up to subclasses to handle cancellation appropriately. The default behavior of calling finish() when cancel() is called can be problematic. * Clarifications to documentation * Handle cancellation in UserLocationProcedure and ReverseGeocodeProcedure Call finish() once the location updates / geocoder are stopped/cancelled. * Add failing test case for DelayProcedure * Tweaks to handling cancellation in DelayProcedure. DelayProcedure should finish() as soon as the timer is cancelled. * Fix DelayProcedure cancellation handling * Fix ReverseGeocodeProcedure/UserLocationProcedure cancellation handling * Update Network*Procedures - Handle cancellation changes. - Special case: hide the URLSessionTask’s cancellation error if the NetworkProcedure was cancelled. - Add comments. * Update ProcessProcedure - Handle cancellation changes. - Special case: hide the Process’s cancellation error if the ProcessProcedure was cancelled. - Add comments. * Add comments * Added more comments. * Fixes building using SwiftPM (#663) * [OPR-633]: Updates project for SwiftPM * [OPR-633]: Removes comments from Package.swift * [OPR-663]: Updates podspecs * [OPR-663]: Fixes ProcedureKitNetwork building in SwiftPM * [OPR-663]: Fixes ProcedureKitCloud for SwiftPM * [OPR-663]: Fixes ProcedureKitLocation for SwiftPM * [OPR-663]: Fixes ProcedureKitMac for SwiftPM * Improve Swift 3 URLError handling in Network*Procedure (#664) * Improve Swift3 URLError handling in NetworkDataProcedure * Improve Swift3 URLError handling in NetworkDownloadProcedure * Improve Swift3 URLError handling in NetworkUploadProcedure * Fixes code signing issue that prevented building release builds (#666) * Fixes typo in link to Dan's github profile (#669) * Procedure EventQueue (#668) * Stress Test tweaks * Improve NetworkObserver testing * StressTestCase: set queue qualityOfService to .userInteractive * Improve ProcedureKitTestCase - Allow for setting `procedure` or `queue` to `nil` before test tearDown. - Set the FinishingProcedure’s name to something descriptive. * Remove old MutualExclusivity tests (The newer, robust MutualExclusivity tests cover these cases and more.) * Procedure utilizes an internal EventQueue The core of Procedure now utilizes an internal EventQueue - a serial FIFO queue onto which all user “events” are dispatched - which results in major thread-safety, performance, and ease-of-use wins, and a reduction in framework overhead. Numerous additional tests are included, edge-case bugs are fixed, and code is simplified. * Add CancellableResultProcedure / CancellableBlockProcedure * Improve the BlockProcedureStressTests * Clean-up Delay.swift Now that Procedure utilizes an internal EventQueue, locks and complexity can be reduced. * Clean-up UserLocationProcedure, ReverseGeocodeProcedure Now that it always safe to call `finish()` from a DidCancel observer, complexity can be reduced. * Improve LogManager / Logger performance - Provide custom `init()` variants for `_Logger` to ensure that only a single LogManager lock acquisition is required. - Adjust `LoggerProtocol` to not query the LogManager (global) state on every call to `log(…)` (which was hurting performance even when logging was disabled). Instead, each Procedure will pick up the current global logging settings when it is instantiated, and can then be further customized. To adjust the settings for all Procedures, simply set the values on LogManager at program start. - Switch LogManager to using a single PThreadMutex lock instead of a Protector for each property for a performance win. * Clean-up NetworkDataProcedure No longer needs a lock for `execute()`+DidCancelObserver. * Clean-up NetworkDownloadProcedure No longer needs a lock for `execute()`+DidCancelObserver. * Clean-up NetworkUploadProcedure No longer needs a lock for `execute()`+DidCancelObserver. * Additional Stress Tests * swiftlint tweaks * ProcessProcedureTests tweak * Improve TestableLocationManager, fix Location tests * Minor clean-up and renaming * Minor clean-up and renaming * Minor clean-up * Minor clean-up and renaming * Renaming PendingEvents * Minor renaming * Minor clean-up and renaming * Minor clean-ups / formatting * Small tweaks and refactoring * Tweaks and refactoring * Rename futureExecute / futureFinish to pendingExecute / pendingFinish * Replace the old Protector with MutexProtector (renamed to: Protector) * Minor tweaks / reformatting * Minor tweaks / renaming * Update comments * Update comments * Additional tests * Test tweak * Minor tweak Resolves a Leak-detector false-positive. * TimeoutObserver documentation tweak (#673) * Limit RetryProcedure to Procedure subclasses (#677) * Limit RetryProcedure to Procedure subclasses * NetworkRecovery fix * Improve AuthorizedFor mutual exclusivity (#679) Previously, an `AuthorizedFor` condition ensured that the Procedure to which it was added was mutually exclusive with any other Procedures with the same `AuthorizedFor` condition (where the base `CapabilityProtocol` was the same). However, what is needed is for the `AuthorizeCapabilityProcedure` (produced by the `AuthorizedFor` condition, and which can trigger a prompt for the capability) to be mutually exclusive with other `AuthorizeCapabilityProcedure`s with the same base CapabilityProtocol. This change ensure that two Procedures do not try to prompt for the same authorization/permission concurrently - but that once they have acquired the authorization/permission, the Procedures may then execute concurrently (unless some other MutuallyExclusive condition or dependency prevents it). * Improves Conditions (#681) * Improve Conditions This encompasses a major refactor of Conditions in ProcedureKit, improving performance, fixing bugs, and adding new features (while also expanding test coverage and documentation). ### The highlights: - Conditions are no longer `Procedure` subclasses, and are lighter-weight. - Condition processing is faster, and supports short-circuit evaluation for considerable performance improvements. - MutualExclusivity is now evaluated post-dependencies and condition evaluation (i.e. immediately before execute), resolving numerous issues and edge cases. - Numerous bugs have been fixed. - Internal implementation details are no longer exposed to user code unexpectedly. - Added a new `CompoundCondition` (and `AndCondition` / `OrCondition`) to support logical “&&” and “||” operations on Conditions. * Additional Mutual Exclusivity test * swiftlint tweaks * CompoundCondition should filter duplicates * Updates SwiftLint rule sets (#689) * [OPR-689]: Updates to latest SwiftLint ruleset Disables some rules globally until we decide on them. * [OPR-689]: Fixes a mistaken weak reference Note - not all “delegates” are weak - otherwise, there is nothing retaining them. * [OPR-689]: Removes the weak delegate from ProcedureKitTestCase Again, not all delegates can be weak. * [OPR-689]: Updates to 10.1 for iOS and tvOS * UserConfirmationCondition (#690) * [OPR-690]: Initial work on UserConfirmationCondition * [OPR-690]: Removes unnecessary API * Uses dependencyCancelledWithErrors error context. (#687) This already existed for NoFailedDependenciesCondition - but wasn’t used by result injection. * AnyProcedure enhancements (#676) * 1. Create AnyInputProcedure and AnyOutputProcedure classes. 2. Replace procedure box with value box. * Formatting. * Fixes Xcode 8.3 warnings for Swift 3.1 (#699) * [swift/3.1]: Fixes warnings for Xcode 8.3 * [swift/3.1]: Fixes warning from Xcode 8.3 in tests * [swift/3.1]: Fix for group errors issue. * [swift/3.1]: Removing dedicated lint step - not needed, as part of build script anway. * [swift/3.1]: Duh, tvOS is still 10.2 not 10.3. * Group._procedureDidCancel should pass on the additional (cancellation) errors to the children (not all errors). * [swift/3.1]: Removes a scenario which could cause an NSOperation to be waiting for itself Bit of an odd situation where the GroupProcedure’s CanFinishGroup internal procedure holds the last strong reference to the group inside it’s execute method, which, causes the group to get deallocated when it goes out of scope, which in turn calls this removed line, which in turns calls `NSOperation.waitUntilFinished` on the CanFinishGroup. The documentation for this states: “An operation object must never call this method on itself and should avoid calling it on any operations submitted to the same operation queue as itself.” which is exactly what is happening. * Update .swiftlint ruleset (#701) * [OPR-701]: Disables identifier_name rule * [OPR-701]: Whitespace fixes * [OPR-701]: Removes unused optional bindings * Procedure's `execute()` function should utilize the ProcedureQueue.underlyingQueue, if set (#708) * Minor enhancements to the DispatchQueue extensions * Procedure's `execute()` function should utilize the ProcedureQueue.underlyingQueue, if set If a Procedure is enqueued on a ProcedureQueue that specifies an `underlyingQueue`, the Procedure’s `execute()` function should run on the underlyingQueue. * Added clearSpecific(key:) to DispatchQueue extensions * Resolve a failed assert in GroupProcedure, and expand the testability of an internal EventQueue synchronization method * Robustness fixes for tests (#710) 1. Two of the dependency-related Condition tests could (rarely) fail due to a race condition in the tests themselves. 2. `test__timeout_observer_where_procedure_is_already_cancelled` could fail because the Procedure was being cancelled via a call to `check(procedure:)` (which executes its block after the Procedure has been added to a queue). 3. Robustness improvements to NetworkObserverTests. The block inside the `TestableNetworkActivityIndicator` is ultimately dispatched asynchronously by the `NetworkActivityController` and, thus, its ordering relative to an individual test finishing (and `tearDown()` being called) may depend on the test specifics and other factors. Therefore, do not use `self._changes`; instead capture the specific `_changes` for the test. 4. Robustness improvements to MutualExclusivityTests 5. Robustness improvements to ProduceTests Not all tests were properly waiting on the `producedOperation` in all cases, and some variables were not properly protected from concurrent reads / writes. 6. Robustness improvements to GroupEventConcurrencyTests `test_group_finish_no_concurrent_events` and `test_group_cancel_no_concurrent_events` both checked for the DidFinish observer to be called, but didn't explicitly wait for it. (The testing harness function `wait(for: Procedure)` may return before DidFinish observers are called because it depends on Operation `isFinished` KVO which is signaled *prior* to DidFinish observers. It may happen that the DidFinish observers are called prior to `wait(for:)` returning, but ordering is not guaranteed.) 7. Robustness improvements to `test__did_finish_synchronized` `test__did_finish_synchronized` could occasionally fail due to a similar issue to 6 above, and is fixed by explicitly waiting for all DidFinish observers to be called. * Robustness fixes for QueueDelegateTests (#711) Several of the `QueueDelegateTests` could (rarely) fail due to a race condition in the tests themselves (related to not properly waiting for the `didFinish` delegate callback). * Robustness fixes for BlockObserverSynchronizationTests (#712) `test__will_add_synchronized` and `test__did_add_synchronized` could (rarely) hit a race condition in the tests themselves and fail. * Robustness fixes for `test__did_add_synchronized` (#713) Resolve a race condition in the test itself. * Fix a (rare) data race in DelayProcedure (#714) Fix a (rare) data race in `DelayProcedure` (discovered via Thread Sanitizer) by ensuring that the `DispatchSourceTimer` is initialized to use the `DelayProcedure`’s internal EventQueue. (The race involved the release of the `DispatchSourceTimer`’s `eventHandler` block.) * Improves .then { } API (#715) * Adjust `then` API for Collections When the `.then` API is used with a Collection of Operations, **all** the operations in the receiver (collection) should be added as dependencies of the argument. * More robust testing * Add compatibility info to README.md * Improve ProcessProcedure (#717) * Improve ProcessProcedure - `ProcessProcedure` is now an `InputProcedure`, and the `LaunchRequest` can be provided via result injection. - `ProcessProcedure` is now an `OutputProcedure`. - `ProcessProcedure` explicitly handles termination due to uncaught signals by default. - `ProcessProcedure` now provides the Process.terminationStatus *and* the Process.terminationReason to the `processDidExitCleanly` handler. - `ProcessProcedure` dispatches the `processDidExitCleanly` and `processDidLaunch ` handlers on its internal, serial EventQueue. - To execute code after the `ProcessProcedure` starts its Process, initialize the `ProcessProcedure` with a `processDidLaunch` handler. (Standard Procedure `DidExecute` observers are no longer guaranteed to execute after the Process has successfully started.) - `ProcessProcedure` no longer uses `DispatchQueue.onMain` internally - instead, it async dispatches to the main queue. - Lots of additional tests and improved tests. * Expand error handling to make it easier to debug programmer error * Adds missing tearDown overrides to CloudKitProcedure tests (#721) * Fix a memory cycle in the testing framework helpers (#722) `makeFinishingProcedure` previously created a memory cycle by: 1. Adding the target procedure as a dependency of the `finishingProcedure` (strong reference: `finishingProcedure` -> target) 2. Adding a ‘WillAddOperation’ observer to the target procedure that captured the `finishingProcedure` (strong reference: target -> `finishingProcedure`) * Resolve redundant conformance constraints [Swift 4] The Swift 4 compiler is stricter, and warns about redundant conformance constraints. * Zero-parameter closure fixes [Swift 4] The Swift 4 compiler is stricter about how zero-parameter closures must be defined. * Fix 'Integer' protocol is unavailable [Swift 4] * Resolve Group/RetryProcedure overridden extension declaration [Swift 4] `Retry.swift:134:24: Declarations from extensions cannot be overridden yet` (The Swift 4 compiler catches a case that the Swift 3 compiler was happy to allow.) Resolved by moving the declaration of `child(_:didAttemptRecoveryFromErrors:)` in Group.swift from an extension of GroupProcedure to the main `class GroupProcedure`. * Logger fix for `closure tuple parameter does not support destructuring` [Swift 4] (#729) `Logging.swift:168:21: Closure tuple parameter '(message: String, severity: LogSeverity, file: String, function: String, line: Int)' does not support destructuring` This was apparently [never really intended to work](https://bugs.swift.org/browse/SR-4738), but there was special-case behavior for a single tuple argument. The Swift 4 compiler is now stricter about rejecting it. * Fix for DispatchQueue `setSpecific` changes [Swift 4] In Swift 4, `DispatchQueue…
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is a particular issue with result injection, which is a result of Swift's initialisation strategy, which means that
requirement
andresult
often need to be explicitly unwrapped optionals.A better way to manage this is to define a different either type, a
PendingValue
e.g.This will allow both
requirement
andresult
properties to now bePendingValue<T>
properties, and ultimately remove the complications of!
all over the place.