Skip to content

Commit 55c2d8e

Browse files
committed
Update to beta 6
1 parent ee531e1 commit 55c2d8e

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

Concurrent/Future.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@
88

99
public struct Future<A> {
1010
let threadID : MVar<Optional<ThreadID>>
11-
let cOptional : IVar<Optional<A>>
11+
let completionLock : IVar<Optional<A>>
1212
let finalizers : MVar<[Optional<A> -> ()]>
1313

1414
private init(_ threadID : MVar<Optional<ThreadID>>, _ cOptional : IVar<Optional<A>>, _ finalizers : MVar<[Optional<A> -> ()]>) {
1515
self.threadID = threadID
16-
self.cOptional = cOptional
16+
self.completionLock = cOptional
1717
self.finalizers = finalizers
1818
}
1919

2020
public func read() -> Optional<A> {
21-
return self.cOptional.read()
21+
return self.completionLock.read()
2222
}
2323

2424
public func then(finalize : Optional<A> -> ()) -> Future<A> {
2525
do {
2626
let ma : Optional<Optional<A>> = try self.finalizers.modify { sTodo in
27-
let res = self.cOptional.tryRead()
27+
let res = self.completionLock.tryRead()
2828
if res == nil {
2929
return (sTodo + [finalize], res)
3030
}
@@ -44,7 +44,7 @@ public struct Future<A> {
4444
}
4545

4646
private func complete(r : Optional<A>) -> Optional<A> {
47-
return self.cOptional.tryPut(r) ? r : self.cOptional.read()
47+
return self.completionLock.tryPut(r) ? r : self.completionLock.read()
4848
}
4949

5050
private func runFinalizerWithOptional<A>(val : Optional<A>) -> (Optional<A> -> ()) -> ThreadID {
@@ -60,10 +60,10 @@ public func forkFutures<A>(ios : [() -> A]) -> Chan<Optional<A>> {
6060

6161
public func forkFuture<A>(io : () throws -> A) -> Future<A> {
6262
let msTid = MVar<ThreadID?>()
63-
let Optional : IVar<A?> = IVar()
63+
let lock : IVar<A?> = IVar()
6464
let msTodo : MVar<[A? -> ()]> = MVar(initial: [])
6565

66-
let p = Future(msTid, Optional, msTodo)
66+
let p = Future(msTid, lock, msTodo)
6767
let act : () -> () = {
6868
p.threadID.put(.Some(myTheadID()))
6969
_ = p.complete({
@@ -80,7 +80,9 @@ public func forkFuture<A>(io : () throws -> A) -> Future<A> {
8080
p.threadID.modify_({ _ in .None })
8181
let val = p.complete(paranoid)
8282
let sTodo = p.finalizers.swap([])
83-
sTodo.forEach { _ in p.runFinalizerWithOptional(val) }
83+
sTodo.forEach { _ in
84+
let _ = p.runFinalizerWithOptional(val)
85+
}
8486
}
8587

8688
_ = forkIO {

Concurrent/SVar.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public struct SVar<A> {
9393
/// have had its value swapped out from under you. It is better to `read()` the values yourself
9494
/// if you need a stricter equality.
9595
public func ==<A : Equatable>(lhs : SVar<A>, rhs : SVar<A>) -> Bool {
96-
if lhs.isEmpty && !rhs.isEmpty {
96+
if lhs.isEmpty && rhs.isEmpty {
9797
return true
9898
}
9999
if lhs.isEmpty != rhs.isEmpty {

0 commit comments

Comments
 (0)