QLinkedList() without dynamic allocation
-
Hello,
I want to use QLinkedList() so that there will be no dynamic allocation.
Upon initialization, all specified space will be allocated.Is it possible ?
I'm using the same QLinkedList() object from multiple threads. Each thread can run on a different core.
Is there any protection when using the same object or should I protect it in my own code ?Best regards,
Z.V -
Hi and welcome to devnet,
Why do you want to specifically use QLinkedList ?
AFAIK, you can't reserve the size of a QLinkedList.
You are responsible to write the protections needed when multiple threads access a shared data.
-
@Zvi-Vered said:
I want to use QLinkedList() so that there will be no dynamic allocation.
Then you don't want to use
QLinkedList
. You would want instead one of the sequential containers -QList
orQVector
. And by the way they still do dynamic allocations, at least when you populate them (if the space is not reserved beforehand). What is it that you're trying to achieve exactly?I'm using the same QLinkedList() object from multiple threads. Is there any protection when using the same object or should I protect it in my own code ?
As pointed out by @SGaist, you should protect your data.