Attempting interface-based consumer
diff --git a/example/main.go b/example/main.go
index fe2d052..9b3f87e 100644
--- a/example/main.go
+++ b/example/main.go
@@ -53,6 +53,8 @@
func consume(written, read *disruptor.Cursor) {
sleeps := 0
+ consumer := SampleConsumer{}
+
previous := int64(-1)
gate := int64(-1)
for previous < Iterations {
@@ -62,11 +64,15 @@
if current <= gate {
for current < gate {
- if ringBuffer[current&BufferMask] > 0 {
- }
-
- current++
+ current += consumer.Consume(current, gate)
}
+ // for current <= gate {
+
+ // if ringBuffer[current&BufferMask] > 0 {
+ // }
+
+ // current++
+ // }
previous = gate
read.Sequence = gate
@@ -93,3 +99,16 @@
// // read.Sequence = sequence
// }
}
+
+type Consumer interface {
+ Consume(lower, upper int64)
+}
+
+type SampleConsumer struct{}
+
+func (this SampleConsumer) Consume(current, gate int64) int64 {
+ if ringBuffer[current&BufferMask] > 0 {
+ }
+
+ return 1
+}