Ring Buffer

Sdílet
Vložit
  • čas přidán 27. 08. 2024

Komentáře • 16

  • @mbeware
    @mbeware Před rokem +2

    great demonstration of a simple implementation of circular buffer. those structure are really useful with Arduino and other microcontroller. I usually reserve a node as an indicator for "overflow/datalost" that might be important to log (or turn on a warning light). I just recreate the node after sending/emptying the buffer and start at 0 instead of -1.

    • @joshrosso
      @joshrosso  Před rokem

      Great idea regarding the overflow indicator 👍🏻

  • @MitchelTighe-sj5fm
    @MitchelTighe-sj5fm Před rokem

    Hey Josh, I'm a young Unix admin with an extremely weak background in computer science so most of your videos go over my head, but I really appreciate the depth you provide in your videos. Just wanted to say thanks your work is appreciated.

    • @joshrosso
      @joshrosso  Před rokem +1

      Keep at it, learning comp sci stuff with a Unix admin background will set you up well!

  • @cococholate
    @cococholate Před rokem +1

    Thank You a lot! You did great job explaining! Its a bit overkill for me still, but you explain it very well! I probably will watch video 10 times until I get everything :)

  • @tuhu5990
    @tuhu5990 Před rokem +1

    Really good video! Like it! Expecting more good quality ones.👍

  • @jefmyers502
    @jefmyers502 Před rokem

    Your videos are great! Thank you!

  • @sternparadis227
    @sternparadis227 Před 4 měsíci +1

    There are several flaws in this implementation of the algorithm which are 'solved' by you using nil values.
    The first problem is in the Insert method. The first value inserted increases _lastInsert_ index by 1. At this point _nextRead_ is 0 and thus equal to _lastInsert_ which is now also 0. This executes the code that increases the _nextRead_ index by 1.
    The second problem lies in the Emit method. When in the loop the last character is read, the loop breaks but the _nextRead_ index is not increased. So the _nextRead_ is still pointing to the previous position.
    As said both problems are obfuscated by the fact you use nil values.

  • @aamonaze
    @aamonaze Před 6 měsíci

    great explained

  • @ChimiChanga1337
    @ChimiChanga1337 Před 2 měsíci

    Hey John, the blog seems to be down.

  • @guavavodka
    @guavavodka Před rokem +1

    what is your zsh/iterm theme?

  • @evanxg852000
    @evanxg852000 Před rokem

    Great tutorial, I got here from the blog post.Please can I know the software you are using to draw over the code editor. I have an xpen device but endup switching on different screens. Also some implementation block the insert/read when its full/empty. My guess is that data loss is ok for your use case.

    • @joshrosso
      @joshrosso  Před rokem +2

      Exactly! My goal/design trade-off here is to intentionally allow for overflow, prioritizing newest data.
      The drawing you're seeing is a screen annotating tool, Presentify.

  • @Lado93
    @Lado93 Před měsícem

    insert method is wrong i think..the if lastInsert == nextRead will be true after first insert. If the nextRead is 0 on init then after insert first insert lastInsert is 0 then the statement is true and you will move the nextRead to 1 and so one and so one. Solution would be to check if the last value of ring buffer N-1 is null or not if is null that mean you yet didn't fill the whole ring buffer else if there is value already then it make sense for the nextRead to move

  • @gimmemoreborisbrejcha9794

    Bro my eyes... make this in a darker background fgs