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. Qt concurrency memory model C++11
QtWS25 Last Chance

Qt concurrency memory model C++11

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 1.9k Views
  • 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.
  • H Offline
    H Offline
    houserockr
    wrote on last edited by
    #1

    Hey Qt folks,

    I've got a general question on Qt's implementation of concurrency (i.e. QThread et al.).
    The new C++ standard introduces a whole new way of concurrency, incorporating a new memory model making it unnecessary to use 3rd party libs like pthread, for instance.

    As far as I know, Qt is currently using the pthread-library - in case of linux - within all concurrency related classes.

    Will Qt make use of the new memory model and the new Thread API of the new C++ standard in future releases? Are there any plans/roadmaps?

    Thanks in advance.

    There are only 10 types of people in the world: those who understand binary and those who don't.

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

      Hi and welcome to devnet,

      You should rather post that question on the interest mailing list, you'll find there Qt's developers/maintainers. This forum is more user oriented

      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
      • H Offline
        H Offline
        houserockr
        wrote on last edited by
        #3

        Thanks! I posted to the interest mailing list.

        There are only 10 types of people in the world: those who understand binary and those who don't.

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          Hi,

          What do you mean by "memory model"?

          Note that std::thread only provides a high-level abstraction layer. On POSIX systems (e.g. Linux), a std::thread is simply a wrapper for a pthread. For example, the function std::thread::native_handle() returns a pthread _t handle! http://en.cppreference.com/w/cpp/thread/thread/native_handle

          In short, std::thread uses pthread similarly to how QThread uses pthread. It removes the requirement for you to write pthread-specific code, but it doesn't remove your program's dependency on pthread.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0
          • H Offline
            H Offline
            houserockr
            wrote on last edited by
            #5

            see http://stackoverflow.com/questions/6319146/c11-introduced-a-standardized-memory-model-what-does-it-mean-and-how-is-it-g

            bq. Of course, you can write multi-threaded code in practice for particular concrete systems -- like pthreads or Windows. But there is no standard way to write multi-threaded code for C++98/C++03.

            bq. The abstract machine in C++11 is multi-threaded by design. It also has a well-defined memory model; that is, it says what the compiler may and may not do when it comes to accessing memory.

            and http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2429.htm

            There are only 10 types of people in the world: those who understand binary and those who don't.

            1 Reply Last reply
            0
            • H Offline
              H Offline
              houserockr
              wrote on last edited by
              #6

              Maybe my expectations on that memory model are too high and libpthread is the "one" who implements the model and makes all the work at the end of the day.

              But I'm certain that something is different (maybe better) in C++11 when it comes to concurrency and my question is: Will Qt incorporate that?

              There are only 10 types of people in the world: those who understand binary and those who don't.

              1 Reply Last reply
              0
              • Chris KawaC Offline
                Chris KawaC Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote on last edited by
                #7

                c++11 memory model is a set of rules what compiler can do and what it can't when it comes to threads. Before there was no such thing as thread in the language dictionary.

                But threading is not something new and there were ways to do it before c++11 via external libraries, either OS provided (e.g. WinAPI CreateThread) or POSIX. Qt builds on top of these.

                There is nothing to incorporate for Qt. It already did threading for years. What's new in c++11 is that you can reason about threading in terms of language specs and not 3rd party libraries.

                The std::thread etc. are not the memory model. The model is just that - a model. It defines what can be moved around in relation to memory barriers. It also says which operations (in the threading context) have undefined behavior. Threading libraries like QtConcurrent, pthreads, std::thread, WinAPi threads (some of which are the same thing) already do that.

                The memory model is just a set of rules that were already there and used widely, just never formally specified and acknowledged by the language. Now they are and have library primitives building on top of that.
                There is no benefit right now to rewrite Qt to use std:: primitives. It would be just switching from red apples to green.

                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