Skip to content

Commit 2be93d7

Browse files
authored
inlineing fixes
1 parent 85178bd commit 2be93d7

File tree

9 files changed

+37
-28
lines changed

9 files changed

+37
-28
lines changed

Futura.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,11 +823,12 @@
823823
ONLY_ACTIVE_ARCH = YES;
824824
OTHER_SWIFT_FLAGS = "-DXcode";
825825
PRODUCT_NAME = "$(TARGET_NAME)";
826-
SDKROOT = macosx;
826+
SDKROOT = "";
827827
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator";
828828
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) SWIFT_PACKAGE DEBUG FUTURA_DEBUG";
829829
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
830830
USE_HEADERMAP = NO;
831+
VALID_ARCHS = "$(VALID_ARCHS)";
831832
};
832833
name = Debug;
833834
};
@@ -847,11 +848,12 @@
847848
MACOSX_DEPLOYMENT_TARGET = 10.12;
848849
OTHER_SWIFT_FLAGS = "-DXcode";
849850
PRODUCT_NAME = "$(TARGET_NAME)";
850-
SDKROOT = macosx;
851+
SDKROOT = "";
851852
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator";
852853
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) SWIFT_PACKAGE";
853854
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
854855
USE_HEADERMAP = NO;
856+
VALID_ARCHS = "$(VALID_ARCHS)";
855857
};
856858
name = Release;
857859
};
@@ -880,7 +882,6 @@
880882
SWIFT_VERSION = 5.0;
881883
TARGET_NAME = Futura;
882884
TVOS_DEPLOYMENT_TARGET = 10.0;
883-
VALID_ARCHS = "arm64 arm64e armv7 armv7s x86_64 i386";
884885
WATCHOS_DEPLOYMENT_TARGET = 4.0;
885886
};
886887
name = Debug;
@@ -910,7 +911,6 @@
910911
SWIFT_VERSION = 5.0;
911912
TARGET_NAME = Futura;
912913
TVOS_DEPLOYMENT_TARGET = 10.0;
913-
VALID_ARCHS = "arm64 arm64e armv7 armv7s x86_64 i386";
914914
WATCHOS_DEPLOYMENT_TARGET = 4.0;
915915
};
916916
name = Release;

Futura.xcodeproj/xcshareddata/xcschemes/Futura.xcscheme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
buildConfiguration = "Debug"
5757
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5858
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
59+
enableThreadSanitizer = "YES"
5960
launchStyle = "0"
6061
useCustomWorkingDirectory = "NO"
6162
ignoresPersistentStateOnLaunch = "NO"

Futura.xcodeproj/xcshareddata/xcschemes/FuturaTest.xcscheme

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
shouldUseLaunchSchemeArgsEnv = "YES">
3131
<Testables>
3232
<TestableReference
33-
skipped = "NO">
33+
skipped = "YES">
3434
<BuildableReference
3535
BuildableIdentifier = "primary"
3636
BlueprintIdentifier = "Futura::FuturaPerformanceTests"
@@ -66,6 +66,7 @@
6666
buildConfiguration = "Debug"
6767
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
6868
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
69+
enableThreadSanitizer = "YES"
6970
launchStyle = "0"
7071
useCustomWorkingDirectory = "NO"
7172
ignoresPersistentStateOnLaunch = "NO"

Sources/Futura/Atomic/AtomicFlag.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ public enum AtomicFlag {
2222
/// Atomic flag is initialized not set (false)
2323
///
2424
/// - Returns: Pointer to new ataomic flag instance
25-
@inline(__always)
25+
@inlinable
2626
public static func make() -> Pointer {
2727
let pointer = Pointer.allocate(capacity: 1)
2828
pointer.pointee = atomic_flag()
2929
return pointer
3030
}
3131

3232
/// - Parameter pointer: Pointer to flag to be destroyed.
33-
@inline(__always)
33+
@inlinable
3434
public static func destroy(_ pointer: Pointer) {
3535
pointer.deinitialize(count: 1)
3636
pointer.deallocate()
@@ -39,15 +39,15 @@ public enum AtomicFlag {
3939
/// Reads current value of flag and sets it to true
4040
///
4141
/// - Parameter pointer: Pointer to flag to be read and set.
42-
@discardableResult @inline(__always)
42+
@discardableResult @inlinable
4343
public static func readAndSet(_ pointer: Pointer) -> Bool {
4444
return atomic_flag_test_and_set(pointer)
4545
}
4646

4747
/// Clears flag (set to false)
4848
///
4949
/// - Parameter pointer: Pointer to flag to be cleared.
50-
@inline(__always)
50+
@inlinable
5151
public static func clear(_ pointer: Pointer) {
5252
atomic_flag_clear(pointer)
5353
}

Sources/Futura/Synchronization/Mutex.swift

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,24 @@ import Darwin.POSIX
1919
#endif
2020

2121
#if os(Linux)
22+
@usableFromInline
2223
fileprivate let nSecMsec: __time_t = 1_000_000
24+
@usableFromInline
2325
fileprivate let mSecSec: __time_t = 1_000 * nSecMsec
2426
#else
25-
fileprivate let nSecMsec: __darwin_time_t = 1_000_000
26-
fileprivate let mSecSec: __darwin_time_t = 1_000 * nSecMsec
27+
@usableFromInline
28+
internal let nSecMsec: __darwin_time_t = 1_000_000
29+
@usableFromInline
30+
internal let mSecSec: __darwin_time_t = 1_000 * nSecMsec
2731
#endif
2832

2933
/// pthread_mutex api wrapper
3034
public enum Mutex {
3135
/// Error thrown on mutex timeout
32-
public struct Timeout: Error {}
36+
public struct Timeout: Error {
37+
@usableFromInline
38+
internal init(){}
39+
}
3340

3441
/// pthread_mutex_t pointer type
3542
public typealias Pointer = UnsafeMutablePointer<pthread_mutex_t>
@@ -40,7 +47,7 @@ public enum Mutex {
4047
///
4148
/// - Parameter recursive: Tells if created mutex should be recursive or not.
4249
/// - Returns: Pointer to new mutex instance
43-
@inline(__always)
50+
@inlinable
4451
public static func make(recursive: Bool) -> Pointer {
4552
let pointer: UnsafeMutablePointer<pthread_mutex_t> = .allocate(capacity: 1)
4653
let attr: UnsafeMutablePointer<pthread_mutexattr_t> = .allocate(capacity: 1)
@@ -57,7 +64,7 @@ public enum Mutex {
5764
/// Deallocates instance of pthread_mutex
5865
///
5966
/// - Parameter pointer: Pointer to mutex to be destroyed.
60-
@inline(__always)
67+
@inlinable
6168
public static func destroy(_ pointer: Pointer) {
6269
pthread_mutex_destroy(pointer)
6370
pointer.deinitialize(count: 1)
@@ -67,7 +74,7 @@ public enum Mutex {
6774
/// Locks on instance of pthread_mutex or waits until unlocked if locked.
6875
///
6976
/// - Parameter pointer: Pointer to mutex to be locked.
70-
@inline(__always)
77+
@inlinable
7178
public static func lock(_ pointer: Pointer) {
7279
pthread_mutex_lock(pointer)
7380
}
@@ -77,7 +84,7 @@ public enum Mutex {
7784
///
7885
/// - Parameter pointer: Pointer to mutex to be locked.
7986
/// - Parameter timeout: Lock wait timeout in seconds.
80-
@inline(__always)
87+
@inlinable
8188
public static func lock(_ pointer: Pointer, timeout: UInt8) throws -> Void {
8289
#if os(Linux)
8390
var currentTimeout = __time_t(timeout) * mSecSec
@@ -104,15 +111,15 @@ public enum Mutex {
104111
///
105112
/// - Parameter pointer: Pointer to mutex to be locked.
106113
/// - Returns: Result of trying to lock. True if succeeded, false otherwise.
107-
@inline(__always)
114+
@inlinable
108115
public static func tryLock(_ pointer: Pointer) -> Bool {
109116
return pthread_mutex_trylock(pointer) == 0
110117
}
111118

112119
/// Unlocks on instance of pthread_mutex
113120
///
114121
/// - Parameter pointer: Pointer to mutex to be unlocked.
115-
@inline(__always)
122+
@inlinable
116123
public static func unlock(_ pointer: Pointer) {
117124
pthread_mutex_unlock(pointer)
118125
}

Sources/Futura/Synchronization/RecursiveLock.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
/// It should not be used to synchronize threads from multiple processes.
1717
public final class RecursiveLock {
1818

19-
/// Reference to underlying mutex.
20-
/// Should not be used - public only for optimizations.
21-
/// All operations on mutex should be performed via public interface of Lock.
22-
public let mtx: Mutex.Pointer = Mutex.make(recursive: true)
19+
@usableFromInline
20+
internal let mtx: Mutex.Pointer = Mutex.make(recursive: true)
2321

2422
/// Creates instance of recursive lock.
2523
public init() {}
@@ -30,7 +28,7 @@ public final class RecursiveLock {
3028

3129
/// Locks if possible or waits until unlocked.
3230
/// Since RecursiveLock is recursive it will continue when already locked on same thread.
33-
@inline(__always)
31+
@inlinable
3432
public func lock() {
3533
Mutex.lock(mtx)
3634
}
@@ -39,28 +37,28 @@ public final class RecursiveLock {
3937
/// Throws an error if time condition was not met
4038
///
4139
/// - Parameter timeout: Lock wait timeout in seconds.
42-
@inline(__always)
40+
@inlinable
4341
public func lock(timeout: UInt8) throws -> Void {
4442
try Mutex.lock(mtx, timeout: timeout)
4543
}
4644

4745
/// Locks if possible and returns true or returns false otherwise without locking.
4846
/// Since RecursiveLock is recursive it will returns true when already locked on same thread.
49-
@inline(__always)
47+
@inlinable
5048
public func tryLock() -> Bool {
5149
return Mutex.tryLock(mtx)
5250
}
5351

5452
/// Unlocks a lock.
55-
@inline(__always)
53+
@inlinable
5654
public func unlock() {
5755
Mutex.unlock(mtx)
5856
}
5957

6058
/// Execute closure with synchronization on self as lock.
6159
/// Since RecursiveLock is recursive you can call synchronized recursively on same thread.
6260
/// It will wait until unlocked if locked when calling.
63-
@inline(__always)
61+
@inlinable
6462
public func synchronized<T>(_ block: () throws -> T) rethrows -> T {
6563
Mutex.lock(mtx)
6664
defer { Mutex.unlock(mtx) }

Sources/Futura/Worker/DispatchQueueWorker.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Dispatch
1616

1717
extension DispatchQueue: Worker {
1818
/// OperationQueue as Worker assigns work to queue using async method.
19+
@inlinable
1920
public func schedule(_ work: @escaping () -> Void) {
2021
async(execute: work)
2122
}

Sources/Futura/Worker/ExecutionContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public enum ExecutionContext {
2525
}
2626

2727
internal extension ExecutionContext {
28-
@inline(__always)
28+
@inlinable
2929
func execute(_ function: @escaping () -> Void) {
3030
switch self {
3131
case .undefined:

Sources/Futura/Worker/OperationQueueWorker.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import Foundation
1717
extension OperationQueue: Worker {
1818
/// OperationQueue as Worker assigns work to queue using addOperation method
1919
/// or executes it immediately if detects it is already on that queue.
20+
@inlinable
2021
public func schedule(_ work: @escaping () -> Void) {
2122
if OperationQueue.current == self {
2223
work()

0 commit comments

Comments
 (0)