Skip to content

Commit

Permalink
Remove inlining annotations
Browse files Browse the repository at this point in the history
Unclear to me if it's supported
  • Loading branch information
digitaliz committed May 17, 2021
1 parent ca1a7a2 commit f32c157
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions Flow/Locking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public final class Mutex {
}
}

@usableFromInline
enum MutexType {
case normal
case recursive
Expand All @@ -54,25 +53,25 @@ enum MutexType {

internal extension pthread_mutex_t {

@inlinable mutating func initialize(as type: MutexType = .normal) {
mutating func initialize(as type: MutexType = .normal) {
withUnsafeMutablePointer(to: &self) {
$0.initialize(as: type)
}
}

@inlinable mutating func deinitialize() {
mutating func deinitialize() {
withUnsafeMutablePointer(to: &self) {
$0.deinitialize()
}
}

@inlinable mutating func lock() {
mutating func lock() {
withUnsafeMutablePointer(to: &self) {
$0.lock()
}
}

@inlinable mutating func unlock() {
mutating func unlock() {
withUnsafeMutablePointer(to: &self) {
$0.unlock()
}
Expand All @@ -85,7 +84,7 @@ typealias PThreadMutex = UnsafeMutablePointer<pthread_mutex_t>
/// Helper methods to work directly with a Pthread mutex pointer to avoid overhead of alloction and reference counting of using the Mutex reference type.
/// - Note: You have to explicity call `initialize()` before use (typically in a class init) and `deinitialize()` when done (typically in a class deinit)
extension UnsafeMutablePointer where Pointee == pthread_mutex_t {
@usableFromInline

func initialize(as type: MutexType = .normal) {
var attr = pthread_mutexattr_t()
defer { pthread_mutexattr_destroy(&attr) }
Expand All @@ -100,23 +99,19 @@ extension UnsafeMutablePointer where Pointee == pthread_mutex_t {
}
}

@usableFromInline
func deinitialize() {
pthread_mutex_destroy(self)
}

/// Attempt to acquire the lock, blocking a thread’s execution until the lock can be acquired.
@usableFromInline
func lock() {
pthread_mutex_lock(self)
}

/// Releases a previously acquired lock.
@usableFromInline
func unlock() {
pthread_mutex_unlock(self)
}

}

/// Internal helper to help manage state in stateful transforms.
Expand Down

0 comments on commit f32c157

Please sign in to comment.