forked from smarty-prototypes/go-disruptor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added significant logging to drive out shared writer race condition.
- Loading branch information
Oliver, Jonathan
committed
May 23, 2014
1 parent
109cfdf
commit cd8fbe6
Showing
6 changed files
with
67 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
package main | ||
|
||
import "github.com/smartystreets/go-disruptor" | ||
import ( | ||
"fmt" | ||
|
||
func publish(writer *disruptor.SharedWriter) { | ||
for { | ||
sequence := writer.Reserve(ItemsToPublish) | ||
"github.com/smartystreets/go-disruptor" | ||
) | ||
|
||
func publish(id int, writer *disruptor.SharedWriter) { | ||
|
||
if sequence != disruptor.Gating { | ||
for lower := sequence - ItemsToPublish; lower < sequence; { | ||
lower++ | ||
ringBuffer[(lower)&RingMask] = lower | ||
} | ||
fmt.Printf("[PRODUCER %d] Starting producer...\n", id) | ||
|
||
for { | ||
if sequence := writer.Reserve(id, ItemsToPublish); sequence != disruptor.Gating { | ||
fmt.Printf("[PRODUCER %d] Writing %d to slot %d\n", id, sequence, sequence) | ||
ringBuffer[sequence&RingMask] = sequence | ||
fmt.Printf("[PRODUCER %d] Committing sequence %d\n", id, sequence) | ||
writer.Commit(sequence) | ||
} else { | ||
// fmt.Println("[PRODUCER] Gating") | ||
//time.Sleep(time.Millisecond) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters