Skip to content

Commit

Permalink
- minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Belozierov committed Apr 4, 2020
1 parent 8989081 commit cf9eb93
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import Darwin
if let pointer = pthread_getspecific(key) {
return Unmanaged<ThreadCoroutineWrapper>.fromOpaque(pointer).takeUnretainedValue()
}
let wrapper = ThreadCoroutineWrapper()
pthread_setspecific(key, Unmanaged.passRetained(wrapper).toOpaque())
return wrapper
let wrapper = Unmanaged.passRetained(ThreadCoroutineWrapper())
pthread_setspecific(key, wrapper.toOpaque())
return wrapper.takeUnretainedValue()
}

private static let key: pthread_key_t = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal final class SharedCoroutine {
internal typealias CompletionState = SharedCoroutineQueue.CompletionState

private enum State: Int {
case running, suspending, suspended, restarting, finished
case running, suspending, suspended, restarting
}

private struct StackBuffer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,4 @@ internal final class SharedCoroutineDispatcher: CoroutineTaskExecutor {
}

}

10 changes: 10 additions & 0 deletions Tests/SwiftCoroutineTests/CoFutureTests/CoFutureTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,14 @@ class CoFutureTests: XCTestCase {
XCTAssertEqual(promise1.hashValue, promise1.hashValue)
}

func testOptional() {
let promise = CoPromise<Int?>()
promise.success(nil)
promise.success(1)
switch promise.result {
case .success(let value) where value == nil: break
default: XCTFail()
}
}

}

0 comments on commit cf9eb93

Please sign in to comment.