Added ability to reserve more than one slot.
diff --git a/example/main.go b/example/main.go
index 6e2674c..4e6ea20 100644
--- a/example/main.go
+++ b/example/main.go
@@ -35,7 +35,7 @@
sequence := disruptor.InitialSequenceValue
writer := disruptor.NewWriter(written, upstream, BufferSize)
for sequence <= Iterations {
- sequence = writer.Reserve()
+ sequence = writer.Reserve(1)
ringBuffer[sequence&BufferMask] = sequence
writer.Commit(sequence)
}
diff --git a/writer.go b/writer.go
index a1bd178..db81008 100644
--- a/writer.go
+++ b/writer.go
@@ -29,8 +29,8 @@
}
}
-func (this *Writer) Reserve() int64 {
- next := this.previous + 1
+func (this *Writer) Reserve(count int64) int64 {
+ next := this.previous + count
for next-this.capacity > this.gate {
this.gate = this.upstream.Read(0)