asynkron / goring Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
Code:
package main
import "github.com/AsynkronIT/goring"
func main() {
q := goring.New(10)
go func() {
for range []int{1, 1, 1, 1, 1, 1, 1, 1, 1, 1} {
q.Push(1)
}
}()
for range []int{1, 1, 1, 1, 1, 1, 1, 1, 1, 1} {
q.Length()
}
}
Output:
yauhen:/home/yauhen/ws/golang/src/playground/1484599026playground>go run -race queue_race_example.go
==================
WARNING: DATA RACE
Read at 0x00c42007a008 by goroutine 6:
sync/atomic.LoadInt64()
/home/yauhen/ws/golang/go/src/runtime/race_amd64.s:211 +0xb
github.com/AsynkronIT/goring.(*Queue).Length()
/home/yauhen/ws/golang/src/github.com/AsynkronIT/goring/queue.go:63 +0x3e
main.main.func2()
/home/yauhen/ws/golang/src/playground/1484599026playground/queue_race_example.go:16 +0x82
Previous write at 0x00c42007a008 by goroutine 5:
github.com/AsynkronIT/goring.(*Queue).Push()
/home/yauhen/ws/golang/src/github.com/AsynkronIT/goring/queue.go:57 +0x463
main.main.func1()
/home/yauhen/ws/golang/src/playground/1484599026playground/queue_race_example.go:10 +0xd6
Goroutine 6 (running) created at:
main.main()
/home/yauhen/ws/golang/src/playground/1484599026playground/queue_race_example.go:18 +0x1e5
Goroutine 5 (finished) created at:
main.main()
/home/yauhen/ws/golang/src/playground/1484599026playground/queue_race_example.go:12 +0x1c3
==================
Found 1 data race(s)
exit status 66
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.