Skip to content

Commit

Permalink
Merge pull request #55 from CodaFi/touch-up
Browse files Browse the repository at this point in the history
Update to Swift 5
  • Loading branch information
CodaFi authored Mar 29, 2019
2 parents c8639a0 + 4b265e0 commit 6095c2c
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 90 deletions.
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ matrix:
include:
- os: osx
language: objective-c
osx_image: xcode9.3
osx_image: xcode10.2
before_install:
- git submodule update --init --recursive
script:
# Restore pod build before shipping for 3.0
# - pod lib lint
- carthage build --no-skip-current
- os: osx
language: objective-c
osx_image: xcode9.3
osx_image: xcode10.2
before_install:
- git submodule update --init --recursive
script:
Expand All @@ -31,9 +29,9 @@ matrix:
before_install:
- git submodule update --init --recursive
- wget -q -O - https://swift.org/keys/all-keys.asc | gpg --import -
- wget https://swift.org/builds/swift-4.1-release/ubuntu1404/swift-4.1-RELEASE/swift-4.1-RELEASE-ubuntu14.04.tar.gz
- tar xzf swift-4.1-RELEASE-ubuntu14.04.tar.gz
- export PATH=${PWD}/swift-4.1-RELEASE-ubuntu14.04/usr/bin:"${PATH}"
- wget https://swift.org/builds/swift-5.0-release/ubuntu1404/swift-5.0-RELEASE/swift-5.0-RELEASE-ubuntu14.04.tar.gz
- tar xzf swift-5.0-RELEASE-ubuntu14.04.tar.gz
- export PATH=${PWD}/swift-5.0-RELEASE-ubuntu14.04/usr/bin:"${PATH}"
script:
- swift test
notifications:
Expand Down
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "typelift/SwiftCheck" "0.10.0"
github "typelift/SwiftCheck" "0.12.0"
133 changes: 67 additions & 66 deletions Concurrent.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:4.0
// swift-tools-version:5.0

import PackageDescription

Expand Down
15 changes: 9 additions & 6 deletions Sources/Concurrent/IChan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@ public struct IChan<A> {
self.init(v)
}

/// Reads all the values from a channel into a list.
/// Reads all the values from a channel into a lazy sequence.
///
/// This computation may block on empty IVars.
public func read() -> [A] {
let (a, ic) = self.ivar.read()
return [a] + ic.read()
/// Though the returned sequence is lazy, this computation may block
/// on reads of empty IVars.
public func read() -> LazySequence<UnfoldSequence<A, IChan<A>>> {
return sequence(state: self, next: { (ichan) -> A in
let (a, ic) = ichan.ivar.read()
defer { ichan = ic }
return a
}).lazy
}


/// Writes a single value to the head of the channel and returns a new write
/// head.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/Concurrent/IVar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public struct IVar<A> {
/// Creates a new `IVar` containing the supplied value.
public init(initial : @autoclosure @escaping () -> A) {
let lock = MVar<()>()
self.init(lock, MVar(initial: initial()), initial)
self.init(lock, MVar(initial: initial()), initial())
}

/// Returns the contents of the `IVar`.
Expand Down
8 changes: 5 additions & 3 deletions Sources/Concurrent/TVar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public final class TVar<T> : Comparable, Hashable {
}

/// The hash value uniquely identifying this `TVar`.
public var hashValue : Int {
return _id
public func hash(into hasher: inout Hasher) {
self._id.hash(into: &hasher)
}

internal var value : TVarType<T>
Expand Down Expand Up @@ -86,7 +86,9 @@ internal final class TVarType<T> : Hashable {
var _fingerprint : Int
var _val : Any

var hashValue : Int { return _fingerprint }
func hash(into hasher: inout Hasher) {
self._fingerprint.hash(into: &hasher)
}

init(_ v : T, _ fingerprint : Int) {
self._fingerprint = fingerprint
Expand Down

0 comments on commit 6095c2c

Please sign in to comment.