Asserting single/exclusive writer performance again--everything looks good.
diff --git a/example/example_consumer.go b/example/example_consumer.go
index 1b32277..9f19705 100644
--- a/example/example_consumer.go
+++ b/example/example_consumer.go
@@ -32,7 +32,7 @@
panic(alert)
}
- ringBuffer[sequence&RingMask] = sequence % 2
+ // ringBuffer[sequence&RingMask] = sequence % 2
}
reader.Commit(lower, upper)
diff --git a/example/example_producer.go b/example/example_producer.go
index ac85259..aaf8c51 100644
--- a/example/example_producer.go
+++ b/example/example_producer.go
@@ -2,7 +2,7 @@
import "github.com/smartystreets/go-disruptor"
-func publish(writer *disruptor.SharedWriter) {
+func publish(writer *disruptor.Writer) {
for {
if lower, upper := writer.Reserve(ItemsToPublish); upper != disruptor.Gating {
diff --git a/example/main.go b/example/main.go
index 7142dce..8e019d8 100644
--- a/example/main.go
+++ b/example/main.go
@@ -8,9 +8,9 @@
const (
MaxConsumersPerGroup = 1
- MaxConsumerGroups = 2
- MaxProducers = 2
- ItemsToPublish = 2
+ MaxConsumerGroups = 1
+ MaxProducers = 1
+ ItemsToPublish = 4
ReportingFrequency = 1000000 * 10 // 1 million * N
RingSize = 1024 * 16
RingMask = RingSize - 1
@@ -22,20 +22,26 @@
runtime.GOMAXPROCS(MaxConsumerGroups*MaxConsumersPerGroup + MaxProducers)
writerCursor := disruptor.NewCursor()
- writerBarrier := disruptor.NewSharedWriterBarrier(writerCursor, RingSize)
+ writerBarrier := disruptor.NewBarrier(writerCursor)
+ // writerBarrier := disruptor.NewSharedWriterBarrier(writerCursor, RingSize)
readerBarrier := startConsumerGroups(writerBarrier, writerCursor)
- writer := disruptor.NewSharedWriter(writerBarrier, readerBarrier)
+ // writer := disruptor.NewSharedWriter(writerBarrier, readerBarrier)
+ writer := disruptor.NewWriter(writerCursor, RingSize, readerBarrier)
- startProducers(writer)
+ startExclusiveProducer(writer)
}
-func startProducers(writer *disruptor.SharedWriter) {
- for i := 0; i < MaxProducers-1; i++ {
- go publish(writer)
- }
-
+func startExclusiveProducer(writer *disruptor.Writer) {
publish(writer)
}
+// func startSharedProducers(writer *disruptor.SharedWriter) {
+// for i := 0; i < MaxProducers-1; i++ {
+// go publish(writer)
+// }
+
+// publish(writer)
+// }
+
func startConsumerGroups(upstream disruptor.Barrier, writer *disruptor.Cursor) disruptor.Barrier {
for i := 0; i < MaxConsumerGroups; i++ {
upstream = startConsumerGroup(i, upstream, writer)