Skip to content

Commit

Permalink
cleaned up README.md a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
bscothern committed Jun 4, 2019
1 parent 0adee88 commit 4aceb59
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

A framework to help with ensure proper usage of `NSLocking` types.

### Carthage
### Swift Package Manager

Include this line in your `Cartfile`:
Update your `Package.swift` to include this to your package dependencies:
```
github "bscothern/ConveniencedLock"
.package(url: "https://github.com/bscothern/ConveniencedLock.git", from: "1.0.2")
```

### Swift Package Manager
### Carthage

Update your `Package.swift` to include this to your package dependencies:
Include this line in your `Cartfile`:
```
.package(url: "https://github.com/bscothern/ConveniencedLock.git", from: "1.0.1")
github "bscothern/ConveniencedLock"
```

## Extensions
Expand All @@ -35,25 +35,23 @@ Creates an instance of a lock while setting its name.

A function that executes a critical section of code while a lock is locked and ensures that it is unlocked after execution.

`@discardableResult public func execute<T>(_ criticalBlock: () throws -> T) rethrows -> T`
`@discardableResult func execute<T>(_ criticalBlock: () throws -> T) rethrows -> T`

### Example Usage
```
import Foundation
import ConveniencedLock
import Foundation
let lock = NSLock(name: "ExampleLock")
var count: Int = 0
for _ in 0 ..< 100 {
DispatchQueue.global().async {
lock.execute {
count += 1
}
DispatchQueue.concurrentPerform(iterations: 1000) { _ in
lock.execute {
count += 1
}
}
// Time to ensure that the dispatch queue blocks have all executed
print(count) // 100
print(count) // 1000
```

0 comments on commit 4aceb59

Please sign in to comment.