Skip to content

Commit

Permalink
feat(runtime): add more logging to understand the MP problem
Browse files Browse the repository at this point in the history
  • Loading branch information
symbiont-stevan-andjelkovic committed Oct 18, 2021
1 parent b960072 commit 44a8f4c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/runtime-prototype/src/Disruptor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,17 @@ data RingBufferMode

data RingBuffer e = RingBuffer
{ rbMode :: RingBufferMode
-- | The capacity, or maximum amount of values, of the ring buffer.
, rbCapacity :: Int64
, rbSequenceNumber :: IORef SequenceNumber
-- | The values of the ring buffer.
, rbEvents :: IOVector e
-- | References to the last consumers' sequence numbers, used in order to
-- avoid wrapping the buffer and overwriting events that have not been
-- consumed yet.
, rbGatingSequences :: IORef [IORef SequenceNumber]
-- | Cached value of computing the last consumers' sequence numbers using the
-- above references.
, rbCachedGatingSequence :: IORef SequenceNumber
-- | Used to keep track of what has been published in the single-producer case.
, rbNextSequence :: IORef SequenceNumber
Expand Down Expand Up @@ -354,8 +358,12 @@ unsafeGet rb current = case rbMode rb of

go = do
v <- getAvailable rb ix
putStrLn ("unsafeGet: v = " ++ show v ++ ", availableValue = " ++ show availableValue)
if v /= availableValue
then go -- XXX: a bit of sleep?
then do
-- XXX: remove
threadDelay 100000
go
else Vector.read (rbEvents rb) ix

get :: RingBuffer e -> SequenceNumber -> IO (Maybe e)
Expand Down

0 comments on commit 44a8f4c

Please sign in to comment.