Interesting that you can even overload <- and -> in Swift. Problem is that
this piece of code here

var (j, more) = <?jobs
if more {
println("received job \(j!)")
} else {
println("received all jobs")
done <- true
looks analogous to Go code, but there is truly a big difference: The sample
code above does not do any blocking. In case the channel is empty it just
exits. In Go the goroutine would be blocked in case the channel were empty.
That goroutine being "lost" then for the scheduler when being blocked is
not a problem in Go as you can easily create some 10k or even 100k
goroutines in Go. But it would be a problem for a language that does not
have some sort of green threads such as Swift where one Swift thread is
represented by one OS thread. So in Swift or some other language with one
thread being represented by one OS thread you would have to revert to
defining some asynchronous callback handler that is invoked when an item is
placed into the channel. And that does not seem to be the case here.

You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 8 | next ›
Discussion Overview
groupgolang-nuts @
postedJun 10, '15 at 2:23p
activeJun 11, '15 at 8:53p



site design / logo © 2022 Grokbase