News for hackers. Stuff that matters.
Re:Network Programming with Go by jesstaa on Sunday June 10, 2012 @08:36AM (#4090879)
You might find that the blocking style of Go networking code is far less mind bending than using twisted.
Re:Network Programming with Go by james4k on Sunday June 10, 2012 @03:34PM (#4091941)
Yes, and the beautiful thing about it, is that the blocking calls you make are actually implemented as evented IO. This is great when you have a large number of goroutines; it keeps it very fast!
Re:Network Programming with Go by chc on Monday June 11, 2012 @01:03PM (#4095606)
Wait, what? Do you have any references for that? My impression was that Go creates new threads for new Goroutines when the current ones are blocked. Is that not how it works?
Re:Network Programming with Go by jesstaa on Tuesday June 12, 2012 @03:52AM (#4099335)
The Go runtime creates new threads to run goroutines when a thread is blocked making a syscall. The net package avoids having too many threads blocking on syscalls by using epoll/kqueue etc. for socket I/O.
Re:Network Programming with Go by baruch on Monday June 11, 2012 @03:42PM (#4096484)
The goroutine is a user-thread, Go can create as many threads as there are cores and schedules user-threads inside these threads without the programmer managing that, you just create goroutines. When a goroutine "blocks" it schedules out from the thread and another can replace it.

http://golang.org/doc/effective_go.html#goroutines

Re:Network Programming with Go by jesstaa on Monday June 11, 2012 @05:56AM (#4093868)
All I/O is evented I/O. It's just that with modern I/O requirements it's too expensive to use a whole thread to wait for the event.