You could look at this library that uses a circular buffer approach for queuing events for asynchronously executing Particle.publish()
But circular buffers are nothing unique to the Particle ecosystem nor confined to microcontrolers. They do exist on any platform.
In a nutshell it’s nothing more than a single array with two variables that hold the head and tail index.
You add new items to at the head location and increment that index.
Once you reach the upper boundary of the array you wrap round to zero and continue till you approach the tail index. There you need to decide whether to overwrite old data or stop adding.
When pulling data out the buffer you do that at the tail index and increment that, till you reach the upper bound, wrap round till you reach the head index, which means you have read all data.
That’s it.
BTW, I found multiple threads with reference to that topic in this forum
e.g. this Circular Buffer - FIFO