UDP data + circular buffer
-
@jsulm said in UDP data + circular buffer:
And is it still there in recent versions
that's a god point, I can't find it in the 5.12 docs. Therefore I don't think so ?
Anyway a basic circular buff is like 40 lines. One should be able to do create on fairly easily with based on e.g. QVector.
-
Ring buffers are only applicable in specialized situations where you need a container of constant memory footprint and quick deque access of elements (such as hardware device I/O. I can see such a thing being in the 3d graphics modules, but its utility in the general framework is very limited. The buffering of incoming UDP is such a case where its utility is valid. There are many online references describing how to implement the ring buffer container.
EDIT: a gotcha that the op needs to be aware of is that you CANNOT create a ring buffer of n characters and expect to access sequences of those characters. each element must be explicitly accessed as a single operation. The reason is that when the head/tail loops back to element n[0] the sequence of characters is no longer contiguous.
-
@jsulm said in UDP data + circular buffer:
@Chanchan You will need to implement the circular buffer by yourself or find existing one. As far as I know Qt does not have such a container.
As said above, there is QQueue.
-
@J.Hilk said in UDP data + circular buffer:
QQueue is not limited in size
Correct. If you need this behavior, you have to check
size()
beforeenqueue()
. -
Actually my case is :
I receive a lot of UDP data, I have to implement a process function to transfert these data to the good function, this function will implement datas, etc...
For this I need a circular buffer, I will take a look on your tips, thank you :)