Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Behind the Scenes
  3. Wiki Discussion
  4. Discussion about "Threads, Events and QObjects" article
Forum Updated to NodeBB v4.3 + New Features

Discussion about "Threads, Events and QObjects" article

Scheduled Pinned Locked Moved Wiki Discussion
59 Posts 17 Posters 45.9k Views 1 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.
  • D Offline
    D Offline
    dangelog
    wrote on last edited by
    #15

    I can put a footnote and/or a link there, just in case. The point is that you should know what QThread::wait() is for. What do you think?

    Software Engineer
    KDAB (UK) Ltd., a KDAB Group company

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #16

      Knowledge about QThread::wait() is definitely needed.

      maybe this wording is a bit more clear:

      "how to start, stop, wait for a thread (aka join a thread in boost and others) under (at least) one major operating system"

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • W Offline
        W Offline
        Wolf P.
        wrote on last edited by
        #17

        [quote author="Volker" date="1292850647"] "how to start, stop, wait for a thread [/quote]
        This sounds very familiar to me (FYI: Win32/VCL).

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #18

          Ok, I changed the sentence to
          [quote]
          how to start and stop a thread, and wait for it to finish, under (at least) one major operating system;
          [/quote]

          Thank you all for your feedback :)

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

          1 Reply Last reply
          0
          • W Offline
            W Offline
            Wolf P.
            wrote on last edited by
            #19

            Another choice of terminology has me confused: reentrant. Thread-safe I understood, but the definition of reentrancy seemed not clearly demarcated from it. Maybe a slight reworking of the text could help for a better understanding of the difference.

            1 Reply Last reply
            0
            • W Offline
              W Offline
              Wolf P.
              wrote on last edited by
              #20

              Sorry for this naive comment. Finally I found that this is Qt terminology: http://doc.qt.nokia.com/latest/threads-reentrancy.html

              1 Reply Last reply
              0
              • F Offline
                F Offline
                Franzk
                wrote on last edited by
                #21

                It is not just Qt terminology. It's general programming terminology and something everyone who does at least the slightest bit of multi-threading should know about.

                http://en.wikipedia.org/wiki/Reentrant_(subroutine)
                http://en.wikipedia.org/wiki/Thread_safety

                "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • W Offline
                  W Offline
                  Wolf P.
                  wrote on last edited by
                  #22

                  [quote author="Franzk" date="1292858262"]...and something everyone who does at least the slightest bit of multi-threading should know about.[/quote] thx for the WP references :)

                  BTW: I did some multithreaded coding without problems, and without thinking about reentrance.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    dangelog
                    wrote on last edited by
                    #23

                    To be honest, the little problem is that there might be some confusion due to literature and/or other toolkits. That's why I specified that in the article I follow the Qt conventions; anyway, I added a link to http://doc.qt.nokia.com/latest/threads-reentrancy.html, just to make it even more clear :-)

                    Software Engineer
                    KDAB (UK) Ltd., a KDAB Group company

                    1 Reply Last reply
                    0
                    • F Offline
                      F Offline
                      Franzk
                      wrote on last edited by
                      #24

                      It's good. The basics are the same across libraries though (bad library if it diverges...).

                      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                      http://www.catb.org/~esr/faqs/smart-questions.html

                      1 Reply Last reply
                      0
                      • W Offline
                        W Offline
                        Wolf P.
                        wrote on last edited by
                        #25

                        After reading "Reentrancy and Thread-Safety":http://doc.qt.nokia.com/latest/threads-reentrancy.html , I think the term reentrance is not the best choice, because re-entering (in a sense of entering it twice) isn't really possible. (My problem seems to be that I'm familiar with the non-reentrance of MS-DOS.)

                        Classes that can be safely used by different threads at different times, I would name just safe. To be honest, I would not discuss it at all, but rather mark those that cannot be used from different threads at different times, maybe as "tread-local" or so.

                        Am I completely wrong here?

                        1 Reply Last reply
                        0
                        • G Offline
                          G Offline
                          giesbert
                          wrote on last edited by
                          #26

                          Hi Wolf,
                          Thread-local is normally used for members/memory. So there is the "ThreadLocalStorage":http://en.wikipedia.org/wiki/Thread-local_storage for example. "Reentrant":http://en.wikipedia.org/wiki/Reentrant_(subroutine) and "thread-safety":http://en.wikipedia.org/wiki/Thread_safety are general terms (from my understanding) which are widely used. So I would stay with the used terms.

                          Nokia Certified Qt Specialist.
                          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                          1 Reply Last reply
                          0
                          • D Offline
                            D Offline
                            dangelog
                            wrote on last edited by
                            #27

                            [quote author="Wolf P." date="1292922748"]
                            Classes that can be safely used by different threads at different times, I would name just safe. To be honest, I would not discuss it at all, but rather mark those that cannot be used from different threads at different times, maybe as "tread-local" or so.

                            Am I completely wrong here?[/quote]

                            There are three possible cases:

                            • Classes/methods/objects/functions/data structures which (...whose instances) can be used at the same time from multiple threads, without the need of serializing cuncurrent accesses. That's what thread-safe means.
                            • Classes/methods/objects/functions/data structures which (...whose instances) cannot be used at the same time from multiple threads, therefore all accesses must be externally serialized. That's what reentrant means. Notice that
                              ** Thread-safe implies reentrant
                              ** Taking a reentrant class and forcibly serializing all possible accesses with a mutex makes it thread-safe
                            • Classes/methods/objects/functions/data structures which (...whose instances) cannot be used from multiple threads at all. There isn't a specific name for this case (we usually say "not thread-safe nor reentrant"). For instance, QWidget and all of its subclasses are usable only from the main thread.

                            Software Engineer
                            KDAB (UK) Ltd., a KDAB Group company

                            1 Reply Last reply
                            0
                            • W Offline
                              W Offline
                              Wolf P.
                              wrote on last edited by
                              #28

                              Ok. The term reentrant (in the given context) is now clear to me.

                              But please note the following example: when you call the Win32 function SendMessage (sending to another process) and get reply-blocked, your process can be re-entered by SendMessage calls from other processes. So, for me, reentrance (in general) has also something to do with recursion.

                              1 Reply Last reply
                              0
                              • W Offline
                                W Offline
                                Wolf P.
                                wrote on last edited by
                                #29

                                I added a toc to the page. (and to the "wiki syntax help":http://developer.qt.nokia.com/wiki/WikiSyntax too)

                                1 Reply Last reply
                                0
                                • G Offline
                                  G Offline
                                  goetz
                                  wrote on last edited by
                                  #30

                                  Unfortunately, the term "reentrancy" is not really clearly defined in computer world.

                                  Michael Suess complains in his "blog entry:"http://www.thinkingparallel.com/2007/06/08/the-most-overused-word-in-parallel-programming-reentrancy/ about the situation. Reading the comments, it seems that there are at least two definitions of reentrancy in the context of single threading (regarding recursive function calls) and in the context of multi threading. This may confuse the people with a single threading background (DOS!) when heading over to multithreaded programming.

                                  Anyways, the definitions are out in the wild and as long as we are in Qt context, we should use the terms defined by the Trolls to avoid further confusion. Otherwise we would need another round of BabelFishing for these kinds of things, but I doubt there's any T-Shirts to win :-)

                                  http://www.catb.org/~esr/faqs/smart-questions.html

                                  1 Reply Last reply
                                  0
                                  • F Offline
                                    F Offline
                                    Franzk
                                    wrote on last edited by
                                    #31

                                    [quote author="Volker" date="1292932902"]but I doubt there's any T-Shirts to win :-)[/quote]Huh, imagine T-shirts stating something about your re-entrancy...

                                    "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                                    http://www.catb.org/~esr/faqs/smart-questions.html

                                    1 Reply Last reply
                                    0
                                    • G Offline
                                      G Offline
                                      goetz
                                      wrote on last edited by
                                      #32

                                      [quote author="Franzk" date="1292935405"][quote author="Volker" date="1292932902"]but I doubt there's any T-Shirts to win :-)[/quote]Huh, imagine T-shirts stating something about your re-entrancy...
                                      [/quote]

                                      What a about

                                      "I'm a male - I'm not thread safe!"

                                      [Edit - ok, a bit offtopic now :-) Volker]

                                      http://www.catb.org/~esr/faqs/smart-questions.html

                                      1 Reply Last reply
                                      0
                                      • F Offline
                                        F Offline
                                        Franzk
                                        wrote on last edited by
                                        #33

                                        "I am NOT re-entrant"

                                        "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                                        http://www.catb.org/~esr/faqs/smart-questions.html

                                        1 Reply Last reply
                                        0
                                        • C Offline
                                          C Offline
                                          changsheng230
                                          wrote on last edited by
                                          #34

                                          Qt also requires that all objects living in a thread are deleted before the QThread object that represents the thread is destroyed; this can be easily done by creating all the objects living in that thread on the QThread::run() method’s stack.

                                          Do you mean that
                                          this can be easily done by deleting all the objects living in that thread on the QThread::run() method’s stack.
                                          ?

                                          Chang Sheng
                                          常升

                                          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