More experiments.
diff --git a/example/main.go b/example/main.go
index e16a54a..6a567d1 100644
--- a/example/main.go
+++ b/example/main.go
@@ -39,6 +39,9 @@
for wrap > gate {
gate = read.Sequence
+ // if wrap > gate {
+ // time.Sleep(time.Microsecond)
+ // }
}
ringBuffer[next&BufferMask] = next
@@ -47,21 +50,17 @@
}
}
func consume(written, read *disruptor.Cursor) {
- sequence := int64(0)
- for sequence < Iterations {
- maximum := written.Sequence
- for maximum <= sequence {
- maximum = written.Sequence
- time.Sleep(time.Microsecond)
- }
-
- for sequence < maximum {
- if ringBuffer[sequence&BufferMask] > 0 {
+ for sequence, gate := int64(0), int64(0); sequence < Iterations; sequence++ {
+ for gate <= sequence {
+ gate = written.Sequence
+ if gate <= sequence {
+ time.Sleep(time.Microsecond)
}
- sequence++
}
- read.Sequence = maximum
- sequence = maximum + 1
+ if ringBuffer[sequence&BufferMask] > 0 {
+ }
+
+ read.Sequence = sequence
}
}