Skip to content

Commit

Permalink
Updating Swift 05-09 (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
czechboy0 committed May 11, 2016
1 parent ab2a313 commit 06b9bbe
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DEVELOPMENT-SNAPSHOT-2016-04-25-a
DEVELOPMENT-SNAPSHOT-2016-05-09-a
14 changes: 7 additions & 7 deletions Source/Venice/Coroutine/Coroutine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,31 @@ public extension Double {
}

/// Runs the expression in a lightweight coroutine.
public func co(_ routine: Void -> Void) {
public func co(_ routine: (Void) -> Void) {
var _routine = routine
CLibvenice.co(&_routine, { routinePointer in
UnsafeMutablePointer<(Void -> Void)>(routinePointer).pointee()
UnsafeMutablePointer<((Void) -> Void)>(routinePointer!).pointee()
}, "co")
}

/// Runs the expression in a lightweight coroutine.
public func co(_ routine: @autoclosure(escaping) Void -> Void) {
var _routine: Void -> Void = routine
public func co(_ routine: @autoclosure(escaping) (Void) -> Void) {
var _routine: (Void) -> Void = routine
CLibvenice.co(&_routine, { routinePointer in
UnsafeMutablePointer<(Void -> Void)>(routinePointer).pointee()
UnsafeMutablePointer<((Void) -> Void)>(routinePointer!).pointee()
}, "co")
}

/// Runs the expression in a lightweight coroutine after the given duration.
public func after(_ napDuration: Double, routine: Void -> Void) {
public func after(_ napDuration: Double, routine: (Void) -> Void) {
co {
nap(for: napDuration)
routine()
}
}

/// Runs the expression in a lightweight coroutine periodically. Call done() to leave the loop.
public func every(_ napDuration: Double, routine: (done: Void -> Void) -> Void) {
public func every(_ napDuration: Double, routine: (done: (Void) -> Void) -> Void) {
co {
var done = false
while !done {
Expand Down
4 changes: 2 additions & 2 deletions Source/Venice/FallibleChannel/FallibleChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public enum ChannelResult<T> {
case value(T)
case error(ErrorProtocol)

public func success(_ closure: @noescape T -> Void) {
public func success(_ closure: @noescape (T) -> Void) {
switch self {
case .value(let value): closure(value)
default: break
}
}

public func failure(_ closure: @noescape ErrorProtocol -> Void) {
public func failure(_ closure: @noescape (ErrorProtocol) -> Void) {
switch self {
case .error(let error): closure(error)
default: break
Expand Down
76 changes: 38 additions & 38 deletions Source/Venice/Select/Select.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ protocol SelectCase {

final class ChannelReceiveCase<T>: SelectCase {
let channel: Channel<T>
let closure: T -> Void
let closure: (T) -> Void

init(channel: Channel<T>, closure: T -> Void) {
init(channel: Channel<T>, closure: (T) -> Void) {
self.channel = channel
self.closure = closure
}
Expand All @@ -51,9 +51,9 @@ final class ChannelReceiveCase<T>: SelectCase {

final class ReceivingChannelReceiveCase<T>: SelectCase {
let channel: ReceivingChannel<T>
let closure: T -> Void
let closure: (T) -> Void

init(channel: ReceivingChannel<T>, closure: T -> Void) {
init(channel: ReceivingChannel<T>, closure: (T) -> Void) {
self.channel = channel
self.closure = closure
}
Expand All @@ -71,9 +71,9 @@ final class ReceivingChannelReceiveCase<T>: SelectCase {

final class FallibleChannelReceiveCase<T>: SelectCase {
let channel: FallibleChannel<T>
var closure: ChannelResult<T> -> Void
var closure: (ChannelResult<T>) -> Void

init(channel: FallibleChannel<T>, closure: ChannelResult<T> -> Void) {
init(channel: FallibleChannel<T>, closure: (ChannelResult<T>) -> Void) {
self.channel = channel
self.closure = closure
}
Expand All @@ -91,9 +91,9 @@ final class FallibleChannelReceiveCase<T>: SelectCase {

final class FallibleReceivingChannelReceiveCase<T>: SelectCase {
let channel: FallibleReceivingChannel<T>
var closure: ChannelResult<T> -> Void
var closure: (ChannelResult<T>) -> Void

init(channel: FallibleReceivingChannel<T>, closure: ChannelResult<T> -> Void) {
init(channel: FallibleReceivingChannel<T>, closure: (ChannelResult<T>) -> Void) {
self.channel = channel
self.closure = closure
}
Expand All @@ -112,9 +112,9 @@ final class FallibleReceivingChannelReceiveCase<T>: SelectCase {
final class ChannelSendCase<T>: SelectCase {
let channel: Channel<T>
var value: T
let closure: Void -> Void
let closure: (Void) -> Void

init(channel: Channel<T>, value: T, closure: Void -> Void) {
init(channel: Channel<T>, value: T, closure: (Void) -> Void) {
self.channel = channel
self.value = value
self.closure = closure
Expand All @@ -132,9 +132,9 @@ final class ChannelSendCase<T>: SelectCase {
final class SendingChannelSendCase<T>: SelectCase {
let channel: SendingChannel<T>
var value: T
let closure: Void -> Void
let closure: (Void) -> Void

init(channel: SendingChannel<T>, value: T, closure: Void -> Void) {
init(channel: SendingChannel<T>, value: T, closure: (Void) -> Void) {
self.channel = channel
self.value = value
self.closure = closure
Expand All @@ -152,9 +152,9 @@ final class SendingChannelSendCase<T>: SelectCase {
final class FallibleChannelSendCase<T>: SelectCase {
let channel: FallibleChannel<T>
let value: T
let closure: Void -> Void
let closure: (Void) -> Void

init(channel: FallibleChannel<T>, value: T, closure: Void -> Void) {
init(channel: FallibleChannel<T>, value: T, closure: (Void) -> Void) {
self.channel = channel
self.value = value
self.closure = closure
Expand All @@ -172,9 +172,9 @@ final class FallibleChannelSendCase<T>: SelectCase {
final class FallibleSendingChannelSendCase<T>: SelectCase {
let channel: FallibleSendingChannel<T>
let value: T
let closure: Void -> Void
let closure: (Void) -> Void

init(channel: FallibleSendingChannel<T>, value: T, closure: Void -> Void) {
init(channel: FallibleSendingChannel<T>, value: T, closure: (Void) -> Void) {
self.channel = channel
self.value = value
self.closure = closure
Expand All @@ -192,9 +192,9 @@ final class FallibleSendingChannelSendCase<T>: SelectCase {
final class FallibleChannelSendErrorCase<T>: SelectCase {
let channel: FallibleChannel<T>
let error: ErrorProtocol
let closure: Void -> Void
let closure: (Void) -> Void

init(channel: FallibleChannel<T>, error: ErrorProtocol, closure: Void -> Void) {
init(channel: FallibleChannel<T>, error: ErrorProtocol, closure: (Void) -> Void) {
self.channel = channel
self.error = error
self.closure = closure
Expand All @@ -212,9 +212,9 @@ final class FallibleChannelSendErrorCase<T>: SelectCase {
final class FallibleSendingChannelSendErrorCase<T>: SelectCase {
let channel: FallibleSendingChannel<T>
let error: ErrorProtocol
let closure: Void -> Void
let closure: (Void) -> Void

init(channel: FallibleSendingChannel<T>, error: ErrorProtocol, closure: Void -> Void) {
init(channel: FallibleSendingChannel<T>, error: ErrorProtocol, closure: (Void) -> Void) {
self.channel = channel
self.error = error
self.closure = closure
Expand All @@ -231,9 +231,9 @@ final class FallibleSendingChannelSendErrorCase<T>: SelectCase {

final class TimeoutCase<T>: SelectCase {
let channel: Channel<T>
let closure: Void -> Void
let closure: (Void) -> Void

init(channel: Channel<T>, closure: Void -> Void) {
init(channel: Channel<T>, closure: (Void) -> Void) {
self.channel = channel
self.closure = closure
}
Expand All @@ -249,79 +249,79 @@ final class TimeoutCase<T>: SelectCase {

public class SelectCaseBuilder {
var cases: [SelectCase] = []
var otherwise: (Void -> Void)?
var otherwise: ((Void) -> Void)?

public func received<T>(valueFrom channel: Channel<T>?, closure: T -> Void) {
public func received<T>(valueFrom channel: Channel<T>?, closure: (T) -> Void) {
if let channel = channel {
let selectCase = ChannelReceiveCase(channel: channel, closure: closure)
cases.append(selectCase)
}
}

public func received<T>(valueFrom channel: ReceivingChannel<T>?, closure: T -> Void) {
public func received<T>(valueFrom channel: ReceivingChannel<T>?, closure: (T) -> Void) {
if let channel = channel {
let selectCase = ReceivingChannelReceiveCase(channel: channel, closure: closure)
cases.append(selectCase)
}
}

public func received<T>(resultFrom channel: FallibleChannel<T>?, closure: ChannelResult<T> -> Void) {
public func received<T>(resultFrom channel: FallibleChannel<T>?, closure: (ChannelResult<T>) -> Void) {
if let channel = channel {
let selectCase = FallibleChannelReceiveCase(channel: channel, closure: closure)
cases.append(selectCase)
}
}

public func received<T>(resultFrom channel: FallibleReceivingChannel<T>?, closure: ChannelResult<T> -> Void) {
public func received<T>(resultFrom channel: FallibleReceivingChannel<T>?, closure: (ChannelResult<T>) -> Void) {
if let channel = channel {
let selectCase = FallibleReceivingChannelReceiveCase(channel: channel, closure: closure)
cases.append(selectCase)
}
}

public func sent<T>(_ value: T, to channel: Channel<T>?, closure: Void -> Void) {
public func sent<T>(_ value: T, to channel: Channel<T>?, closure: (Void) -> Void) {
if let channel = channel where !channel.closed {
let selectCase = ChannelSendCase(channel: channel, value: value, closure: closure)
cases.append(selectCase)
}
}

public func sent<T>(_ value: T, to channel: SendingChannel<T>?, closure: Void -> Void) {
public func sent<T>(_ value: T, to channel: SendingChannel<T>?, closure: (Void) -> Void) {
if let channel = channel where !channel.closed {
let selectCase = SendingChannelSendCase(channel: channel, value: value, closure: closure)
cases.append(selectCase)
}
}

public func sent<T>(_ value: T, to channel: FallibleChannel<T>?, closure: Void -> Void) {
public func sent<T>(_ value: T, to channel: FallibleChannel<T>?, closure: (Void) -> Void) {
if let channel = channel where !channel.closed {
let selectCase = FallibleChannelSendCase(channel: channel, value: value, closure: closure)
cases.append(selectCase)
}
}

public func sent<T>(_ value: T, to channel: FallibleSendingChannel<T>?, closure: Void -> Void) {
public func sent<T>(_ value: T, to channel: FallibleSendingChannel<T>?, closure: (Void) -> Void) {
if let channel = channel where !channel.closed {
let selectCase = FallibleSendingChannelSendCase(channel: channel, value: value, closure: closure)
cases.append(selectCase)
}
}

public func sent<T>(_ error: ErrorProtocol, to channel: FallibleChannel<T>?, closure: Void -> Void) {
public func sent<T>(_ error: ErrorProtocol, to channel: FallibleChannel<T>?, closure: (Void) -> Void) {
if let channel = channel where !channel.closed {
let selectCase = FallibleChannelSendErrorCase(channel: channel, error: error, closure: closure)
cases.append(selectCase)
}
}

public func sent<T>(_ error: ErrorProtocol, to channel: FallibleSendingChannel<T>?, closure: Void -> Void) {
public func sent<T>(_ error: ErrorProtocol, to channel: FallibleSendingChannel<T>?, closure: (Void) -> Void) {
if let channel = channel where !channel.closed {
let selectCase = FallibleSendingChannelSendErrorCase(channel: channel, error: error, closure: closure)
cases.append(selectCase)
}
}

public func timedOut(_ deadline: Double, closure: Void -> Void) {
public func timedOut(_ deadline: Double, closure: (Void) -> Void) {
let done = Channel<Bool>()
co {
wake(at: deadline)
Expand All @@ -331,7 +331,7 @@ public class SelectCaseBuilder {
cases.append(selectCase)
}

public func otherwise(_ closure: Void -> Void) {
public func otherwise(_ closure: (Void) -> Void) {
self.otherwise = closure
}
}
Expand All @@ -342,7 +342,7 @@ private func select(_ builder: SelectCaseBuilder) {
var clauses: [UnsafeMutablePointer<Void>] = []

for (index, selectCase) in builder.cases.enumerated() {
let clause = malloc(mill_clauselen())
let clause = malloc(mill_clauselen())!
clauses.append(clause)
selectCase.register(clause, index: index)
}
Expand Down Expand Up @@ -372,7 +372,7 @@ public func sel(_ build: @noescape (when: SelectCaseBuilder) -> Void) {
select(build)
}

public func forSelect(_ build: @noescape (when: SelectCaseBuilder, done: Void -> Void) -> Void) {
public func forSelect(_ build: @noescape (when: SelectCaseBuilder, done: (Void) -> Void) -> Void) {
let builder = SelectCaseBuilder()
var keepRunning = true
func done() {
Expand All @@ -385,6 +385,6 @@ public func forSelect(_ build: @noescape (when: SelectCaseBuilder, done: Void ->
}
}

public func forSel(build: @noescape (when: SelectCaseBuilder, done: Void -> Void) -> Void) {
public func forSel(build: @noescape (when: SelectCaseBuilder, done: (Void) -> Void) -> Void) {
forSelect(build)
}
2 changes: 1 addition & 1 deletion Tests/Venice/VeniceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class VeniceTests: XCTestCase {
}

extension VeniceTests {
static var allTests : [(String, VeniceTests -> () throws -> Void)] {
static var allTests : [(String, (VeniceTests) -> () throws -> Void)] {
return [
("testReality", testReality),
]
Expand Down

0 comments on commit 06b9bbe

Please sign in to comment.