Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ring buffer data structures #1147

Open
harendra-kumar opened this issue Jul 22, 2021 · 4 comments
Open

Ring buffer data structures #1147

harendra-kumar opened this issue Jul 22, 2021 · 4 comments
Assignees
Labels
aspect:arrays Arrays and array streams
Milestone

Comments

@harendra-kumar
Copy link
Member

Make ring buffer a first class streaming citizen by providing read unfold and write fold for it just like array. That will enable us to use ringbuffers more e.g. lastN can actually return a ringbuffer instead of array.

@harendra-kumar harendra-kumar added this to the 0.8.2 milestone Nov 23, 2021
@harendra-kumar
Copy link
Member Author

PR #1340 added signatures for the ring buffer APIs. Let's implement those.

@harendra-kumar harendra-kumar added the aspect:arrays Arrays and array streams label Nov 23, 2021
@adithyaov adithyaov modified the milestones: 0.8.2, 0.9.0 Feb 20, 2022
@adithyaov adithyaov modified the milestones: 0.9.0, 0.10.0 Jun 14, 2022
@harendra-kumar harendra-kumar modified the milestones: 0.10.0, 0.11.0 Jul 13, 2023
@adithyaov
Copy link
Member

This will also require extensive testing.

@adithyaov
Copy link
Member

adithyaov commented Jul 9, 2024

Ring buffer user-facing APIs

Currently, the user-facing APIs of the ring buffer are not very safe. It's very
easy to shoot yourself in the foot when uninitialized elements are involved.

The internal representation can be extended to keep track of things
like ringLength, ringHead, etc.

Possibly,

data Ring a = Ring
    { ringContents :: {-# UNPACK #-} !MutByteArray
    , ringHead :: {-# UNPACK #-} !Int     -- ^ Write index
    , ringTail :: {-# UNPACK #-} !Int     -- ^ Read index
    , ringLength :: {-# UNPACK #-} !Int   -- ^ Buffer length
    , ringCapacity :: {-# UNPACK #-} !Int -- ^ Buffer capacity
    }

@adithyaov
Copy link
Member

This can be closed. Most of the ring changes have been merged into master.
See: #2832

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aspect:arrays Arrays and array streams
Projects
None yet
Development

No branches or pull requests

2 participants