Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QLinkedList() without dynamic allocation
Forum Updated to NodeBB v4.3 + New Features

QLinkedList() without dynamic allocation

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 633 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Zvi VeredZ Offline
    Zvi VeredZ Offline
    Zvi Vered
    wrote on last edited by
    #1

    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

    kshegunovK 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Zvi VeredZ Zvi Vered

        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

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by kshegunov
        #3

        @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 or QVector. 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.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved