Skip to content

Commit

Permalink
Add chanbuf nums.
Browse files Browse the repository at this point in the history
  • Loading branch information
toomore committed May 5, 2015
1 parent 3ed1361 commit 6e47905
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/realtime/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ func prettyprint(data realtime.Data) string {
data.TradeTime, data.SysInfo["sysDate"], data.SysInfo["sysTime"])
}

var chanbuf int

func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
chanbuf = runtime.NumCPU() * 2
}

var twseNo = flag.String("twse", "", "上市股票代碼,可使用 ',' 分隔多組代碼,例:2618,2329")
Expand All @@ -97,7 +100,7 @@ var index = flag.Bool("index", false, "顯示大盤、上櫃、寶島指數(de

func main() {
flag.Parse()
queue := make(chan *realtime.StockRealTime, runtime.NumCPU())
queue := make(chan *realtime.StockRealTime, chanbuf)
defer close(queue)
var wg sync.WaitGroup

Expand Down

0 comments on commit 6e47905

Please sign in to comment.