Skip to content

Commit 7bc65c0

Browse files
committed
Merge branch 'CocoaPods'
2 parents f99ba7e + a5edb3d commit 7bc65c0

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

go.swift

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,29 @@ private let pt_entry: @objc_block (UnsafeMutablePointer<Void>) -> UnsafeMutableP
3535
}
3636
private var pt_entry_imp = imp_implementationWithBlock(unsafeBitCast(pt_entry, AnyObject.self))
3737
private let pt_entry_fp = CFunctionPointer<(UnsafeMutablePointer<Void>) -> UnsafeMutablePointer<Void>>(pt_entry_imp)
38-
func dispatch_thread(block : ()->()){
38+
public func dispatch_thread(block : ()->()){
3939
let p = UnsafeMutablePointer<()->()>.alloc(1)
4040
p.initialize(block)
4141
var t = pthread_t()
4242
pthread_create(&t, nil, pt_entry_fp, p)
4343
pthread_detach(t)
4444
}
45-
protocol Locker {
45+
public protocol Locker {
4646
func lock()
4747
func unlock()
4848
}
49-
class Mutex : Locker {
49+
public class Mutex : Locker {
5050
private var mutex = pthread_mutex_t()
5151
init(){
5252
pthread_mutex_init(&mutex, nil)
5353
}
5454
deinit{
5555
pthread_mutex_destroy(&mutex)
5656
}
57-
func lock(){
57+
public func lock(){
5858
pthread_mutex_lock(&mutex)
5959
}
60-
func unlock(){
60+
public func unlock(){
6161
pthread_mutex_unlock(&mutex)
6262
}
6363
func lock(closure:()->()){
@@ -66,7 +66,7 @@ class Mutex : Locker {
6666
unlock()
6767
}
6868
}
69-
class Cond {
69+
public class Cond {
7070
private var cond = pthread_cond_t()
7171
private var mutex : Mutex
7272
init(locker : Locker){
@@ -94,7 +94,7 @@ class Cond {
9494
pthread_cond_wait(&cond, &mutex.mutex)
9595
}
9696
}
97-
class Once {
97+
public class Once {
9898
private var mutex = Mutex()
9999
private var oncer = false
100100
func doit(closure:()->()){
@@ -108,7 +108,7 @@ class Once {
108108
mutex.unlock()
109109
}
110110
}
111-
class WaitGroup {
111+
public class WaitGroup {
112112
private var cond = Cond(locker: Mutex())
113113
private var count = 0
114114
func add(delta : Int){
@@ -131,15 +131,15 @@ class WaitGroup {
131131
cond.locker.unlock()
132132
}
133133
}
134-
protocol ChanAny {
134+
public protocol ChanAny {
135135
func receive(wait : Bool, mutex : Mutex?, inout flag : Bool) -> (msg : Any?, ok : Bool, ready : Bool)
136136
func send(msg : Any?)
137137
func close()
138138
func signal()
139139
func count() -> Int
140140
func capacity() -> Int
141141
}
142-
class Chan<T> : ChanAny {
142+
public class Chan<T> : ChanAny {
143143
private var msgs = [Any?]()
144144
private var cap = 0
145145
private var cond = Cond(locker: Mutex())
@@ -151,24 +151,24 @@ class Chan<T> : ChanAny {
151151
init(buffer: Int){
152152
cap = buffer
153153
}
154-
func count() -> Int{
154+
public func count() -> Int{
155155
if cap == 0 {
156156
return 0
157157
}
158158
return msgs.count
159159
}
160-
func capacity() -> Int{
160+
public func capacity() -> Int{
161161
return cap
162162
}
163-
func close(){
163+
public func close(){
164164
cond.locker.lock()
165165
if !closed {
166166
closed = true
167167
cond.broadcast()
168168
}
169169
cond.locker.unlock()
170170
}
171-
func send(msg: Any?) {
171+
public func send(msg: Any?) {
172172
cond.locker.lock()
173173
if closed {
174174
cond.locker.unlock()
@@ -181,7 +181,7 @@ class Chan<T> : ChanAny {
181181
}
182182
cond.locker.unlock()
183183
}
184-
func receive(wait : Bool, mutex : Mutex?, inout flag : Bool) -> (msg : Any?, ok : Bool, ready : Bool) {
184+
public func receive(wait : Bool, mutex : Mutex?, inout flag : Bool) -> (msg : Any?, ok : Bool, ready : Bool) {
185185
// Peek
186186
if !wait {
187187
cond.locker.lock()
@@ -242,33 +242,33 @@ class Chan<T> : ChanAny {
242242
cond.wait()
243243
}
244244
}
245-
func signal(){
245+
public func signal(){
246246
cond.broadcast()
247247
}
248248
}
249249
infix operator <- { associativity right precedence 155 }
250250
prefix operator <- { }
251251
prefix operator <? { }
252-
func <-<T>(l: Chan<T>, r: T?){
252+
public func <-<T>(l: Chan<T>, r: T?){
253253
l.send(r)
254254
}
255-
prefix func <?<T>(r: Chan<T>) -> (T?, Bool){
255+
public prefix func <?<T>(r: Chan<T>) -> (T?, Bool){
256256
var flag = false
257257
let (v, ok, ready) = r.receive(true, mutex: nil, flag: &flag)
258258
return (v as? T, ok)
259259
}
260-
prefix func <-<T>(r: Chan<T>) -> T?{
260+
public prefix func <-<T>(r: Chan<T>) -> T?{
261261
var flag = false
262262
let (v, ok, ready) = r.receive(true, mutex: nil, flag: &flag)
263263
return v as? T
264264
}
265-
func close<T>(chan : Chan<T>){
265+
public func close<T>(chan : Chan<T>){
266266
chan.close()
267267
}
268-
func len<T>(chan : Chan<T>) -> Int{
268+
public func len<T>(chan : Chan<T>) -> Int{
269269
return chan.count()
270270
}
271-
func cap<T>(chan : Chan<T>) -> Int{
271+
public func cap<T>(chan : Chan<T>) -> Int{
272272
return chan.capacity()
273273
}
274274
private struct GoPanicError {
@@ -489,27 +489,27 @@ private class GoApp {
489489
}
490490
}
491491
private let goapp = GoApp()
492-
func $(closure: ()->()){
492+
public func $(closure: ()->()){
493493
goapp.routine().$(closure)
494494
}
495-
func go(closure: ()->()){
495+
public func go(closure: ()->()){
496496
goapp.go(closure)
497497
}
498-
func defer(file : StaticString = __FILE__, line : UWord = __LINE__, closure: ()->()){
498+
public func defer(file : StaticString = __FILE__, line : UWord = __LINE__, closure: ()->()){
499499
goapp.routine().defer(file: file, line: line, closure: closure)
500500
}
501-
func panic(what : AnyObject, file : StaticString = __FILE__, line : UWord = __LINE__){
501+
public func panic(what : AnyObject, file : StaticString = __FILE__, line : UWord = __LINE__){
502502
goapp.routine().panic(what, file: file, line: line)
503503
}
504-
func recover(file : StaticString = __FILE__, line : UWord = __LINE__) -> AnyObject? {
504+
public func recover(file : StaticString = __FILE__, line : UWord = __LINE__) -> AnyObject? {
505505
return goapp.routine().recover(file: file, line: line)
506506
}
507-
func select(file : StaticString = __FILE__, line : UWord = __LINE__, closure:()->()) {
507+
public func select(file : StaticString = __FILE__, line : UWord = __LINE__, closure:()->()) {
508508
goapp.routine().select(file: file, line: line, closure: closure)
509509
}
510-
func _case<T>(l : Chan<T>, file : StaticString = __FILE__, line : UWord = __LINE__, closure:(msg : T?, ok : Bool)->()) {
510+
public func _case<T>(l : Chan<T>, file : StaticString = __FILE__, line : UWord = __LINE__, closure:(msg : T?, ok : Bool)->()) {
511511
goapp.routine().case_(l, file: file, line: line, closure: { (msg, ok) in closure(msg: msg as? T, ok: ok) })
512512
}
513-
func _default(file : StaticString = __FILE__, line : UWord = __LINE__, closure:()->()) {
513+
public func _default(file : StaticString = __FILE__, line : UWord = __LINE__, closure:()->()) {
514514
goapp.routine().default_(file: file, line: line, closure: closure)
515515
}

0 commit comments

Comments
 (0)