About 'Circular Or Ring Buffers'!

In this video (objectives)…

  1. Note we've changed to Unity 2017.3.1
  2. Introduce a new mnemonic www.wow
  3. Overview ring or circular buffers
  4. Briefly discuss performance and memory fragmentation.

After watching (learning outcomes)…

Explain in simple terms what a ring buffer is.

(Unique Video Reference: 32_RR_CU2)

We would love to know…

  • What you found good about this lecture?
  • What we could do better?

Remember that you can reply to this topic, or create a new topic. The easiest way to create a new topic is to follow the link in Resources. That way the topic will…

  • Be in the correct forum (for the course).
  • Be in the right sub-forum (for the section)
  • Have the correct lecture tag.

Enjoy your stay in our thriving community!

Basically, we are shaping the queue as a ring with first following right after last. This ring will go around storing the positions of the towers, overwriting any position that already exists in the spot. I think this will be accomplished FIFO, dequeueing (deleting the first, making the next one first) and then enqueueing (adding the new to the end, thus keeping the same numver of towers).

1 Like

I chose to implement my ringbuffer as an array and a pointer to an array element instead since then the underlying data structure wouldn’t be changing size, which I imagine would happen with a queue even if the tower instances would persist themselves and that would lead to memory reservation/freeing again.

This is based on an assumption the C# Queue doesn’t use some kind of an array approach internally which won’t get resized unless necessary, I don’t know though!

Which is better? Ring buffer or Object Pool?

Well a pool doesn’t necessarily have any order attached to it, so depending on whether that metadata is useful to you or not changes which is better

Rubber Chicken? Professional programmers don’t talk to rubber chickens! That would be silly.

They talk to rubber ducks. https://blog.codinghorror.com/rubber-duck-problem-solving/

Privacy & Terms