qt6-bb10/tests/auto/corelib
Marc Mutz d6c8fab880 QMutex: make sure we try_lock_for no shorter than the duration passed
By templating on the <chrono> types and unconditionally using
duration_cast to coerce the duration into a milliseconds, we
allowed code such as

   mutex.try_lock_for(10us)

to compile, which is misleading, since it's actually a zero-
timeout try_lock().

Feedback from the std-discussions mailing list is that the
wait_for functions should wait for _at least_ the duration
given, because that is the natural direction of variance
(tasks becoming ready to run might not get a CPU immediately,
causing delays), while an interface that documents to wait
_no more_ than the given duration is promising something it
cannot fulfill.

Fix by converting the given duration to the smallest number
of milliseconds not less than the original duration. If that
is not representable in an int, use INT_MAX, emulating the
effect of a spurious wakeup, which are allowed to happen if
the function returns false in that case.

In the above example, the try_lock_for call is now equivalent
to

  mutex.tryLock(1);

The tryLock() docs state that the actual waiting time does
not exceed the given milliseconds, but fixing that is a
separate issue.

Change-Id: Id4cbbea0ecc6fd2f94bb5aef28a1658be3728e52
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-11-22 11:32:35 +00:00
..
animation QtCore: Remove Windows CE. 2016-03-30 11:22:47 +00:00
codecs tests/auto/corelib/codecs: clean up 2016-08-06 14:49:21 +00:00
global tst_qhooks: test that it's possible to chain multiple hooks together 2016-11-18 15:22:32 +00:00
io Fix missing last modification time stamp in qrc content 2016-11-22 04:57:02 +00:00
itemmodels Merge remote-tracking branch 'origin/5.7' into dev 2016-08-16 07:58:32 +02:00
json Merge remote-tracking branch 'origin/5.7' into 5.8 2016-11-16 12:35:36 +01:00
kernel Remove compiler-specific implementations of Q_IS_ENUM 2016-11-09 09:13:01 +00:00
mimetypes tests/auto/corelib/mimetypes: use local QThreadPool 2016-09-17 06:47:05 +00:00
plugin Convert the old feature system 2016-09-15 08:24:10 +00:00
statemachine Merge "Merge remote-tracking branch 'origin/5.6' into dev" into refs/staging/dev 2016-01-26 11:27:37 +00:00
thread QMutex: make sure we try_lock_for no shorter than the duration passed 2016-11-22 11:32:35 +00:00
tools Replace custom type traits with std one's 2016-11-08 15:31:17 +00:00
xml tests/auto/corelib/xml: cleanup 2016-08-27 05:09:16 +00:00
corelib.pro Add support for Apple tvOS 2016-05-17 16:11:23 +00:00