Skip to content

Commit

Permalink
Testing multiple reservations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver, Jonathan committed Jun 5, 2014
1 parent be66d4e commit 803d6ec
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions example/main.go
Expand Up @@ -12,7 +12,7 @@ const (
BufferSize = 1024 * 64
BufferMask = BufferSize - 1
Iterations = 1000000 * 100
Reservations = 1
Reservations = 16
)

var ring = [BufferSize]int64{}
Expand All @@ -39,18 +39,23 @@ func publish(writer *disruptor.Writer) {
sequence := disruptor.InitialSequenceValue
for sequence <= Iterations {
sequence = writer.Reserve(Reservations)
ring[sequence&BufferMask] = sequence
writer.Commit(sequence, sequence)
for lower := sequence - Reservations + 1; lower <= sequence; lower++ {
ring[lower&BufferMask] = lower
}

writer.Commit(sequence-Reservations+1, sequence)
}
}

// func publish(writer *disruptor.Writer) {
// sequence := disruptor.InitialSequenceValue
// for sequence <= Iterations {
// sequence += Reservations
// sequence += Reservations // only an advantage at smaller reservations, e.g. 1-4?
// writer.Await(sequence)
// ring[sequence&BufferMask] = sequence
// writer.Commit(sequence, sequence)
// for lower := sequence - Reservations + 1; lower <= sequence; lower++ {
// ring[lower&BufferMask] = lower
// }
// writer.Commit(sequence-Reservations+1, sequence)
// }
// }

Expand Down

0 comments on commit 803d6ec

Please sign in to comment.