@@ -31,7 +31,7 @@ public protocol Locker {
31
31
}
32
32
public class Mutex : Locker {
33
33
private var mutex = pthread_mutex_t ( )
34
- init ( ) {
34
+ public init ( ) {
35
35
pthread_mutex_init ( & mutex, nil )
36
36
}
37
37
deinit {
@@ -52,7 +52,7 @@ public class Mutex : Locker {
52
52
public class Cond {
53
53
private var cond = pthread_cond_t ( )
54
54
private var mutex : Mutex
55
- init ( locker : Locker ) {
55
+ public init ( locker : Locker ) {
56
56
if let m = locker as? Mutex {
57
57
self . mutex = m
58
58
} else {
@@ -80,7 +80,7 @@ public class Cond {
80
80
public class Once {
81
81
private var mutex = Mutex ( )
82
82
private var oncer = false
83
- func doit( closure: ( ) -> ( ) ) {
83
+ public func doit( closure: ( ) -> ( ) ) {
84
84
mutex. lock ( )
85
85
if oncer{
86
86
mutex. unlock ( )
@@ -94,7 +94,7 @@ public class Once {
94
94
public class WaitGroup {
95
95
private var cond = Cond ( locker: Mutex ( ) )
96
96
private var count = 0
97
- func add( delta : Int ) {
97
+ public func add( delta : Int ) {
98
98
cond. locker. lock ( )
99
99
count += delta
100
100
if count < 0 {
@@ -103,10 +103,10 @@ public class WaitGroup {
103
103
cond. broadcast ( )
104
104
cond. locker. unlock ( )
105
105
}
106
- func done( ) {
106
+ public func done( ) {
107
107
add ( - 1 )
108
108
}
109
- func wait( ) {
109
+ public func wait( ) {
110
110
cond. locker. lock ( )
111
111
while count > 0 {
112
112
cond. wait ( )
@@ -128,13 +128,13 @@ public class Chan<T> : ChanAny {
128
128
private var cond = Cond ( locker: Mutex ( ) )
129
129
private var closed = false
130
130
131
- convenience init ( ) {
131
+ public convenience init ( ) {
132
132
self . init ( 0 )
133
133
}
134
- init ( _ buffer: Int ) {
134
+ public init ( _ buffer: Int ) {
135
135
cap = buffer
136
136
}
137
- init ( buffer: Int ) {
137
+ public init ( buffer: Int ) {
138
138
cap = buffer
139
139
}
140
140
public func count( ) -> Int {
@@ -260,7 +260,7 @@ public func cap<T>(chan : Chan<T>) -> Int{
260
260
private struct GoPanicError {
261
261
var what : AnyObject ?
262
262
var file : StaticString = " "
263
- var line : UWord = 0
263
+ var line : UInt = 0
264
264
}
265
265
private class GoRoutineStack {
266
266
var error = GoPanicError ( )
@@ -298,7 +298,7 @@ private class GoRoutine {
298
298
}
299
299
}
300
300
}
301
- func panic( what : AnyObject , file : StaticString = __FILE__, line : UWord = __LINE__) {
301
+ func panic( what : AnyObject , file : StaticString = __FILE__, line : UInt = __LINE__) {
302
302
if stack. count == 0 {
303
303
fatalError ( " \( what) " , file: file, line: line)
304
304
}
@@ -309,7 +309,7 @@ private class GoRoutine {
309
309
longjmp ( s. jump, 1 )
310
310
}
311
311
}
312
- func recover( file : StaticString = __FILE__, line : UWord = __LINE__) -> AnyObject ? {
312
+ func recover( file : StaticString = __FILE__, line : UInt = __LINE__) -> AnyObject ? {
313
313
if stack. count == 0 {
314
314
fatalError ( " missing ${} context " , file: file, line: line)
315
315
}
@@ -331,7 +331,7 @@ private class GoRoutine {
331
331
}
332
332
return ints
333
333
}
334
- func select( file : StaticString = __FILE__, line : UWord = __LINE__, closure: ( ) -> ( ) ) {
334
+ func select( file : StaticString = __FILE__, line : UInt = __LINE__, closure: ( ) -> ( ) ) {
335
335
${
336
336
let s = self . stack. last!
337
337
s. select = true
@@ -384,15 +384,15 @@ private class GoRoutine {
384
384
}
385
385
}
386
386
}
387
- func case_( chan : ChanAny , file : StaticString = __FILE__, line : UWord = __LINE__, closure: ( msg : Any ? , ok : Bool ) -> ( ) ) {
387
+ func case_( chan : ChanAny , file : StaticString = __FILE__, line : UInt = __LINE__, closure: ( msg : Any ? , ok : Bool ) -> ( ) ) {
388
388
if stack. count == 0 || !stack. last!. select {
389
389
fatalError ( " missing select{} context " , file: file, line: line)
390
390
}
391
391
let s = stack. last!
392
392
s. cases. append ( closure)
393
393
s. chans. append ( chan)
394
394
}
395
- func default_( file : StaticString = __FILE__, line : UWord = __LINE__, closure: ( ) -> ( ) ) {
395
+ func default_( file : StaticString = __FILE__, line : UInt = __LINE__, closure: ( ) -> ( ) ) {
396
396
if stack. count == 0 || !stack. last!. select {
397
397
fatalError ( " missing select{} context " , file: file, line: line)
398
398
}
@@ -470,18 +470,18 @@ public func $(closure: ()->()){
470
470
public func go( closure: ( ) -> ( ) ) {
471
471
goapp. go ( closure)
472
472
}
473
- public func panic( what : AnyObject , file : StaticString = __FILE__, line : UWord = __LINE__) {
473
+ public func panic( what : AnyObject , file : StaticString = __FILE__, line : UInt = __LINE__) {
474
474
goapp. routine ( ) . panic ( what, file: file, line: line)
475
475
}
476
- public func recover( file : StaticString = __FILE__, line : UWord = __LINE__) -> AnyObject ? {
476
+ public func recover( file : StaticString = __FILE__, line : UInt = __LINE__) -> AnyObject ? {
477
477
return goapp. routine ( ) . recover ( file, line: line)
478
478
}
479
- public func select( file : StaticString = __FILE__, line : UWord = __LINE__, closure: ( ) -> ( ) ) {
479
+ public func select( file : StaticString = __FILE__, line : UInt = __LINE__, closure: ( ) -> ( ) ) {
480
480
goapp. routine ( ) . select ( file, line: line, closure: closure)
481
481
}
482
- public func _case< T> ( l : Chan < T > , file : StaticString = __FILE__, line : UWord = __LINE__, closure: ( msg : T ? , ok : Bool ) -> ( ) ) {
482
+ public func _case< T> ( l : Chan < T > , file : StaticString = __FILE__, line : UInt = __LINE__, closure: ( msg : T ? , ok : Bool ) -> ( ) ) {
483
483
goapp. routine ( ) . case_ ( l, file: file, line: line, closure: { ( msg, ok) in closure ( msg: msg as? T , ok: ok) } )
484
484
}
485
- public func _default( file : StaticString = __FILE__, line : UWord = __LINE__, closure: ( ) -> ( ) ) {
485
+ public func _default( file : StaticString = __FILE__, line : UInt = __LINE__, closure: ( ) -> ( ) ) {
486
486
goapp. routine ( ) . default_ ( file, line: line, closure: closure)
487
487
}
0 commit comments