mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-24 18:31:41 +01:00
WIP
This commit is contained in:
@@ -33,7 +33,7 @@ internal extension CoreStoreFetchRequest {
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
@nonobjc
|
||||
@nonobjc @inline(__always)
|
||||
internal func dynamicCast<U: NSFetchRequestResult>() -> NSFetchRequest<U> {
|
||||
|
||||
return unsafeBitCast(self, to: NSFetchRequest<U>.self)
|
||||
|
||||
@@ -30,7 +30,7 @@ import Foundation
|
||||
|
||||
internal extension DispatchQueue {
|
||||
|
||||
@nonobjc
|
||||
@nonobjc @inline(__always)
|
||||
internal static func serial(_ label: String, qos: DispatchQoS = .default) -> DispatchQueue {
|
||||
|
||||
return DispatchQueue(
|
||||
@@ -42,7 +42,7 @@ internal extension DispatchQueue {
|
||||
)
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
@nonobjc @inline(__always)
|
||||
internal static func concurrent(_ label: String, qos: DispatchQoS = .default) -> DispatchQueue {
|
||||
|
||||
return DispatchQueue(
|
||||
@@ -54,7 +54,7 @@ internal extension DispatchQueue {
|
||||
)
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
@nonobjc @inline(__always)
|
||||
internal func cs_isCurrentExecutionContext() -> Bool {
|
||||
|
||||
let specific = ObjectIdentifier(self)
|
||||
@@ -63,25 +63,25 @@ internal extension DispatchQueue {
|
||||
return DispatchQueue.getSpecific(key: Static.specificKey) == specific
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
@nonobjc @inline(__always)
|
||||
internal func cs_sync<T>(_ closure: () throws -> T) rethrows -> T {
|
||||
|
||||
return try self.sync { try autoreleasepool(invoking: closure) }
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
@nonobjc @inline(__always)
|
||||
internal func cs_async(_ closure: @escaping () -> Void) {
|
||||
|
||||
self.async { autoreleasepool(invoking: closure) }
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
@nonobjc @inline(__always)
|
||||
internal func cs_barrierSync<T>(_ closure: () throws -> T) rethrows -> T {
|
||||
|
||||
return try self.sync(flags: .barrier) { try autoreleasepool(invoking: closure) }
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
@nonobjc @inline(__always)
|
||||
internal func cs_barrierAsync(_ closure: @escaping () -> Void) {
|
||||
|
||||
self.async(flags: .barrier) { autoreleasepool(invoking: closure) }
|
||||
|
||||
@@ -27,6 +27,7 @@ import Foundation
|
||||
|
||||
// MARK: Associated Objects
|
||||
|
||||
@inline(__always)
|
||||
internal func cs_getAssociatedObjectForKey<T: AnyObject>(_ key: UnsafeRawPointer, inObject object: Any) -> T? {
|
||||
|
||||
switch objc_getAssociatedObject(object, key) {
|
||||
@@ -42,16 +43,19 @@ internal func cs_getAssociatedObjectForKey<T: AnyObject>(_ key: UnsafeRawPointer
|
||||
}
|
||||
}
|
||||
|
||||
@inline(__always)
|
||||
internal func cs_setAssociatedRetainedObject<T: AnyObject>(_ associatedObject: T?, forKey key: UnsafeRawPointer, inObject object: Any) {
|
||||
|
||||
objc_setAssociatedObject(object, key, associatedObject, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
||||
}
|
||||
|
||||
@inline(__always)
|
||||
internal func cs_setAssociatedCopiedObject<T: AnyObject>(_ associatedObject: T?, forKey key: UnsafeRawPointer, inObject object: Any) {
|
||||
|
||||
objc_setAssociatedObject(object, key, associatedObject, .OBJC_ASSOCIATION_COPY_NONATOMIC)
|
||||
}
|
||||
|
||||
@inline(__always)
|
||||
internal func cs_setAssociatedWeakObject<T: AnyObject>(_ associatedObject: T?, forKey key: UnsafeRawPointer, inObject object: Any) {
|
||||
|
||||
if let associatedObject = associatedObject {
|
||||
@@ -67,26 +71,31 @@ internal func cs_setAssociatedWeakObject<T: AnyObject>(_ associatedObject: T?, f
|
||||
|
||||
// MARK: Printing Utilities
|
||||
|
||||
@inline(__always)
|
||||
internal func cs_typeName<T>(_ value: T) -> String {
|
||||
|
||||
return "'\(String(reflecting: type(of: value)))'"
|
||||
}
|
||||
|
||||
@inline(__always)
|
||||
internal func cs_typeName<T>(_ value: T.Type) -> String {
|
||||
|
||||
return "'\(value)'"
|
||||
}
|
||||
|
||||
@inline(__always)
|
||||
internal func cs_typeName(_ value: AnyClass) -> String {
|
||||
|
||||
return "'\(value)'"
|
||||
}
|
||||
|
||||
@inline(__always)
|
||||
internal func cs_typeName(_ name: String) -> String {
|
||||
|
||||
return "<\(name)>"
|
||||
}
|
||||
|
||||
@inline(__always)
|
||||
internal func cs_typeName(_ name: String?) -> String {
|
||||
|
||||
return "<\(name ?? "unknown")>"
|
||||
|
||||
Reference in New Issue
Block a user