Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-25197

Ambiguous QWaitCondition::wait return-value documentation

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 4.8.x
    • Core: Threads
    • None

    Description

      QWaitCondition::wait states the returned value as follows:

      // -------
      The mutex will be unlocked, and the calling thread will block until either of these conditions is met:

      • Another thread signals it using wakeOne() or wakeAll(). This function will return true in this case.
      • time milliseconds has elapsed. If time is ULONG_MAX (the default), then the wait will never timeout (the event must be signalled). This function will return false if the wait timed out.
        // --------

      This leaves open what is returned when both anoter thread calles "wakeOne" or "wakeAll" and the "time milliseconds" has elapsed. Since you cannot ensure in a waking thread that the time has not yet elapsed when calling "wake*" (due to scheduling/execution delays and the weak definition of "thread signals it using ..."), essentially any use of a timeout "wait" with a corresponding "wake*" is undefined or not sufficiently defined behavior.

      Attachments

        For Gerrit Dashboard: QTBUG-25197
        # Subject Branch Project Status CR V

        Activity

          People

            Unassigned Unassigned
            litb Johannes Schaub
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes