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 bug #79

Open
parubets opened this issue Sep 4, 2021 · 2 comments
Open

ring buffer bug #79

parubets opened this issue Sep 4, 2021 · 2 comments

Comments

@parubets
Copy link

parubets commented Sep 4, 2021

Hello!

Anyone has an idea why is this happening? :)

Interactive Elixir (1.12.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :ets_buffer.create(:small, :ring, 6)
:ets_buffer
iex(2)> :ets_buffer.write(:small, "1")
1
iex(3)> :ets_buffer.write(:small, "2")
2
iex(4)> :ets_buffer.write(:small, "3")
3
iex(5)> :ets_buffer.write(:small, "4")
4
iex(6)> :ets_buffer.read(:small, 1)
["1"]
iex(7)> :ets_buffer.read(:small, 1)
["2"]
iex(8)> :ets_buffer.read(:small, 1)
["3"]
iex(9)> :ets_buffer.read(:small, 1)
["4"]
iex(10)> :ets_buffer.read(:small, 1)
[]
iex(11)> :ets_buffer.write(:small, "5")
1
iex(12)> :ets_buffer.write(:small, "6")
2
iex(13)> :ets_buffer.write(:small, "7")
3
iex(14)> :ets_buffer.read(:small, 1)
["5", "6"]
iex(15)> :ets_buffer.read(:small, 1)
{:missing_ets_data, :small, -1}
iex(16)> :ets_buffer.read(:small, 1)
["7"]
iex(17)> :ets_buffer.read(:small, 1)
[]
iex(18)>

on iex line 14 ring buffer suddenly returns 2 elements, and on the line 15 :missing_ets_data error

@jaynel
Copy link
Member

jaynel commented Sep 6, 2021

I have not mantained this repo for several years now.

@parubets
Copy link
Author

parubets commented Sep 7, 2021

yes, I noticed that :) but it's still very good and beautiful implementation, that's why I wanted to try it out :)
I don't think it's related to some dependency updates, more likely an error in logic. I thought it would be easy for you to spot an error :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants