Comments (2)
The way I use it cause data race.
=== RUN TestGoDisruptorMultipleProducer
==================
WARNING: DATA RACE
Read at 0x00c000070560 by goroutine 9:
github.com/smartystreets-prototypes/go-disruptor.(*DefaultWriter).Reserve()
D:/proj/mine/gopath/pkg/mod/github.com/smartystreets-prototypes/[email protected]/default_writer.go:28 +0x5c
web/business/taskqueuepackage/test_test.publish()
D:/proj/mine/gopath/src/gitee-server/business/taskqueuepackage/test/GoDisruptorMultipleProducer_test.go:29 +0xc6
Previous write at 0x00c000070560 by goroutine 8:
github.com/smartystreets-prototypes/go-disruptor.(*DefaultWriter).Reserve()
D:/proj/mine/gopath/pkg/mod/github.com/smartystreets-prototypes/[email protected]/default_writer.go:28 +0x78
web/business/taskqueuepackage/test_test.publish()
D:/proj/mine/gopath/src/gitee-server/business/taskqueuepackage/test/GoDisruptorMultipleProducer_test.go:29 +0xc6
Goroutine 9 (running) created at:
web/business/taskqueuepackage/test_test.TestGoDisruptorMultipleProducer()
D:/proj/mine/gopath/src/gitee-server/business/taskqueuepackage/test/GoDisruptorMultipleProducer_test.go:21 +0x18c
testing.tRunner()
D:/go/src/testing/testing.go:909 +0x1a0
Goroutine 8 (running) created at:
web/business/taskqueuepackage/test_test.TestGoDisruptorMultipleProducer()
D:/proj/mine/gopath/src/gitee-server/business/taskqueuepackage/test/GoDisruptorMultipleProducer_test.go:21 +0x18c
testing.tRunner()
D:/go/src/testing/testing.go:909 +0x1a0
==================
==================
WARNING: DATA RACE
Read at 0x00c000070568 by goroutine 9:
github.com/smartystreets-prototypes/go-disruptor.(*DefaultWriter).Reserve()
D:/proj/mine/gopath/pkg/mod/github.com/smartystreets-prototypes/[email protected]/default_writer.go:29 +0x137
web/business/taskqueuepackage/test_test.publish()
D:/proj/mine/gopath/src/gitee-server/business/taskqueuepackage/test/GoDisruptorMultipleProducer_test.go:29 +0xc6
Previous write at 0x00c000070568 by goroutine 8:
github.com/smartystreets-prototypes/go-disruptor.(*DefaultWriter).Reserve()
D:/proj/mine/gopath/pkg/mod/github.com/smartystreets-prototypes/[email protected]/default_writer.go:34 +0xce
web/business/taskqueuepackage/test_test.publish()
D:/proj/mine/gopath/src/gitee-server/business/taskqueuepackage/test/GoDisruptorMultipleProducer_test.go:29 +0xc6
Goroutine 9 (running) created at:
web/business/taskqueuepackage/test_test.TestGoDisruptorMultipleProducer()
D:/proj/mine/gopath/src/gitee-server/business/taskqueuepackage/test/GoDisruptorMultipleProducer_test.go:21 +0x18c
testing.tRunner()
D:/go/src/testing/testing.go:909 +0x1a0
Goroutine 8 (running) created at:
web/business/taskqueuepackage/test_test.TestGoDisruptorMultipleProducer()
D:/proj/mine/gopath/src/gitee-server/business/taskqueuepackage/test/GoDisruptorMultipleProducer_test.go:21 +0x18c
testing.tRunner()
D:/go/src/testing/testing.go:909 +0x1a0
And the DefaultWriter
seems should be used in only a goroutine?
func (this *DefaultWriter) Reserve(count int64) int64 {
if count <= 0 {
panic(ErrMinimumReservationSize)
}
this.previous += count
for spin := int64(0); this.previous-this.capacity > this.gate; spin++ {
if spin&SpinMask == 0 {
runtime.Gosched() // LockSupport.parkNanos(1L); http://bit.ly/1xiDINZ
}
this.gate = this.upstream.Load()
}
return this.previous
}
from go-disruptor.
Right now it only supports a single producer.
If you want to do multiple producers, the only workaround is to do:
mutex.Lock()
// claim
// write
mutex.Unlock()
from go-disruptor.
Related Issues (11)
- multiProducers and multiConsumers HOT 1
- consume process hung HOT 5
- ringBuffer visibility discuss
- Ask : Is Go-Disruptor ready / safe for production ? or Is there any inprogress job ? HOT 2
- It seem the test is hangup HOT 1
- Is this repo active ? HOT 2
- About 'SharedWriter.Reserve' parameter 'count' HOT 1
- Eliminate race condition in the AMD64 cursor HOT 8
- reader.go has sleep HOT 1
- Why allocate new local var(lower,upper) inside loop instead of allocate outside that.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-disruptor.