[tor-commits] [snowflake/master] Use chan struct{} instead of chan bool in openChan.
dcf at torproject.org
dcf at torproject.org
Mon Jan 18 11:27:15 UTC 2016
commit a77ae6b771e5550b3a5370f7b1f2c0e434f4e9eb
Author: David Fifield <david at bamsoftware.com>
Date: Mon Jan 18 03:04:39 2016 -0800
Use chan struct{} instead of chan bool in openChan.
http://dave.cheney.net/2014/03/25/the-empty-struct
"...there is one important practical use of empty structs, and that is
the chan struct{} construct used for signaling between go routines"
---
client/snowflake.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/client/snowflake.go b/client/snowflake.go
index ae87f89..da609b3 100644
--- a/client/snowflake.go
+++ b/client/snowflake.go
@@ -104,7 +104,7 @@ func dialWebRTC(config *webrtc.Configuration, meek *MeekChannel) (
offerChan := make(chan *webrtc.SessionDescription)
errChan := make(chan error)
- openChan := make(chan bool)
+ openChan := make(chan struct{})
pc, err := webrtc.NewPeerConnection(config)
if err != nil {
@@ -151,7 +151,7 @@ func dialWebRTC(config *webrtc.Configuration, meek *MeekChannel) (
}
dc.OnOpen = func() {
log.Println("OnOpen channel")
- openChan <- true
+ openChan <- struct{}{}
}
dc.OnClose = func() {
log.Println("OnClose channel")
More information about the tor-commits
mailing list