From 342e1eccf305ba2bf3627d2a45593d170d1416e7 Mon Sep 17 00:00:00 2001 From: BB9z Date: Tue, 21 May 2019 10:49:40 +0800 Subject: [PATCH 1/6] Update project setting. --- Atomic.xcodeproj/project.pbxproj | 30 ++++++++++++++++++- .../xcshareddata/xcschemes/Atomic.xcscheme | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Atomic.xcodeproj/project.pbxproj b/Atomic.xcodeproj/project.pbxproj index 0ab818c..5128061 100644 --- a/Atomic.xcodeproj/project.pbxproj +++ b/Atomic.xcodeproj/project.pbxproj @@ -185,7 +185,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0710; - LastUpgradeCheck = 0710; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Adlai Holler"; TargetAttributes = { CC6035571C136EE4003ED664 = { @@ -204,6 +204,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = CC60354E1C136EE4003ED664; @@ -284,17 +285,28 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -322,6 +334,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -332,17 +345,28 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -362,6 +386,8 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -373,6 +399,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -391,6 +418,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; diff --git a/Atomic.xcodeproj/xcshareddata/xcschemes/Atomic.xcscheme b/Atomic.xcodeproj/xcshareddata/xcschemes/Atomic.xcscheme index ae3a448..209d480 100644 --- a/Atomic.xcodeproj/xcshareddata/xcschemes/Atomic.xcscheme +++ b/Atomic.xcodeproj/xcshareddata/xcschemes/Atomic.xcscheme @@ -1,6 +1,6 @@ Date: Tue, 21 May 2019 10:50:23 +0800 Subject: [PATCH 2/6] Fix build, @noescape is the default now. --- Atomic/Atomic.swift | 4 ++-- Atomic/Lock.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Atomic/Atomic.swift b/Atomic/Atomic.swift index a44fd64..a1a4c42 100644 --- a/Atomic/Atomic.swift +++ b/Atomic/Atomic.swift @@ -44,7 +44,7 @@ public final class Atomic { /// Atomically modifies the variable. /// /// Returns the old value. - public func modify(@noescape action: (Value) throws -> Value) rethrows -> Value { + public func modify(action: (Value) throws -> Value) rethrows -> Value { return try lock.withCriticalScope { let oldValue = _value _value = try action(_value) @@ -56,7 +56,7 @@ public final class Atomic { /// variable. /// /// Returns the result of the action. - public func withValue(@noescape action: (Value) throws -> Result) rethrows -> Result { + public func withValue(action: (Value) throws -> Result) rethrows -> Result { return try lock.withCriticalScope { try action(_value) } diff --git a/Atomic/Lock.swift b/Atomic/Lock.swift index b79ce22..fd4e735 100644 --- a/Atomic/Lock.swift +++ b/Atomic/Lock.swift @@ -39,9 +39,9 @@ final public class Lock { } extension Lock { - public func withCriticalScope(@noescape body: () throws -> Result) rethrows -> Result { + public func withCriticalScope(body: () throws -> Result) rethrows -> Result { lock() defer { unlock() } return try body() } -} \ No newline at end of file +} From a1074c8f1cad9294b4a4fd100e69ba369e868682 Mon Sep 17 00:00:00 2001 From: BB9z Date: Tue, 21 May 2019 10:56:10 +0800 Subject: [PATCH 3/6] Update test. --- AtomicTests/AtomicTests.swift | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/AtomicTests/AtomicTests.swift b/AtomicTests/AtomicTests.swift index 90f8c31..6298c1c 100644 --- a/AtomicTests/AtomicTests.swift +++ b/AtomicTests/AtomicTests.swift @@ -38,7 +38,7 @@ class AtomicTests: XCTestCase { func testSwap() { let atomic = Atomic(1) - let oldValue = atomic.swap(25) + let oldValue = atomic.swap(newValue: 25) XCTAssertEqual(oldValue, 1) XCTAssertEqual(atomic._value, 25) } @@ -85,22 +85,22 @@ class AtomicTests: XCTestCase { func testHighlyContestedLocking() { let contestedAtomic = Atomic(0) - let concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) - let dispatchGroup = dispatch_group_create() + let concurrentQueue = DispatchQueue.global() + let dispatchGroup = DispatchGroup() let count = 100_000 for _ in 0.. Date: Tue, 21 May 2019 10:57:16 +0800 Subject: [PATCH 4/6] Restore swap() behaivor. --- Atomic/Atomic.swift | 2 +- AtomicTests/AtomicTests.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Atomic/Atomic.swift b/Atomic/Atomic.swift index a1a4c42..2c4f487 100644 --- a/Atomic/Atomic.swift +++ b/Atomic/Atomic.swift @@ -37,7 +37,7 @@ public final class Atomic { /// Atomically replaces the contents of the variable. /// /// Returns the old value. - public func swap(newValue: Value) -> Value { + public func swap(_ newValue: Value) -> Value { return modify { _ in newValue } } diff --git a/AtomicTests/AtomicTests.swift b/AtomicTests/AtomicTests.swift index 6298c1c..6076b12 100644 --- a/AtomicTests/AtomicTests.swift +++ b/AtomicTests/AtomicTests.swift @@ -38,7 +38,7 @@ class AtomicTests: XCTestCase { func testSwap() { let atomic = Atomic(1) - let oldValue = atomic.swap(newValue: 25) + let oldValue = atomic.swap(25) XCTAssertEqual(oldValue, 1) XCTAssertEqual(atomic._value, 25) } From 39c15dd7daae22643f864573fe22532b400a4c0f Mon Sep 17 00:00:00 2001 From: BB9z Date: Tue, 21 May 2019 11:01:33 +0800 Subject: [PATCH 5/6] Old value should be discardable. --- Atomic/Atomic.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Atomic/Atomic.swift b/Atomic/Atomic.swift index 2c4f487..bb586b9 100644 --- a/Atomic/Atomic.swift +++ b/Atomic/Atomic.swift @@ -37,14 +37,14 @@ public final class Atomic { /// Atomically replaces the contents of the variable. /// /// Returns the old value. - public func swap(_ newValue: Value) -> Value { + @discardableResult public func swap(_ newValue: Value) -> Value { return modify { _ in newValue } } /// Atomically modifies the variable. /// /// Returns the old value. - public func modify(action: (Value) throws -> Value) rethrows -> Value { + @discardableResult public func modify(action: (Value) throws -> Value) rethrows -> Value { return try lock.withCriticalScope { let oldValue = _value _value = try action(_value) From 2cb0d20c928e61d89fd21bb58c4a1f0c948f8ad2 Mon Sep 17 00:00:00 2001 From: BB9z Date: Tue, 21 May 2019 11:12:02 +0800 Subject: [PATCH 6/6] Bump podspec. --- Atomic.podspec | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Atomic.podspec b/Atomic.podspec index 73e655d..cf22cd7 100644 --- a/Atomic.podspec +++ b/Atomic.podspec @@ -1,17 +1,18 @@ Pod::Spec.new do |s| s.name = 'Atomic' - s.version = '1.0.3' + s.version = '1.1.0' s.license = 'MIT' s.summary = 'Atomic is a fast, safe way to make values atomic (thread-safe).' s.homepage = 'https://github.com/Adlai-Holler/Atomic' s.social_media_url = 'http://twitter.com/adlaih' s.authors = { 'Adlai Holler' => 'him@adlai.io' } - s.source = { :git => 'https://github.com/Adlai-Holler/Atomic.git', :tag => 'v1.0.3' } + s.source = { :git => 'https://github.com/Adlai-Holler/Atomic.git', :tag => 'v1.1.0' } s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.10' s.source_files = 'Atomic/*.swift' + s.swift_version = '5.0' s.requires_arc = true end