QtBase  v6.3.1
src_corelib_kernel_qdeadlinetimer.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2018 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the documentation of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** BSD License Usage
18 ** Alternatively, you may use this file under the terms of the BSD license
19 ** as follows:
20 **
21 ** "Redistribution and use in source and binary forms, with or without
22 ** modification, are permitted provided that the following conditions are
23 ** met:
24 ** * Redistributions of source code must retain the above copyright
25 ** notice, this list of conditions and the following disclaimer.
26 ** * Redistributions in binary form must reproduce the above copyright
27 ** notice, this list of conditions and the following disclaimer in
28 ** the documentation and/or other materials provided with the
29 ** distribution.
30 ** * Neither the name of The Qt Company Ltd nor the names of its
31 ** contributors may be used to endorse or promote products derived
32 ** from this software without specific prior written permission.
33 **
34 **
35 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
46 **
47 ** $QT_END_LICENSE$
48 **
49 ****************************************************************************/
50 
52  void executeOperation(int msecs)
53  {
54  QDeadlineTimer deadline(msecs);
55  do {
56  if (readFromDevice(deadline.remainingTime()))
57  break;
59  } while (!deadline.hasExpired());
60  }
62 
64  using namespace std::chrono;
65  using namespace std::chrono_literals;
66 
68  device->waitForReadyRead(deadline);
69  if (deadline.remainingTime<nanoseconds>() > 300ms)
70  cleanup();
72 
74  using namespace std::chrono;
75  using namespace std::chrono_literals;
80 
82  using namespace std::chrono_literals;
85 
87  using namespace std::chrono_literals;
90 
94 
97  if (realTimeLeft != (std::numeric_limits<qint64>::max)()) {
99  // or:
100  //QElapsedTimer timer;
101  //timer.start();
102  //realTimeLeft -= timer.msecsSinceReference();
103  }
105 
108  if (realTimeLeft != std::numeric_limits<qint64>::max())
111 
113  return d1.deadlineNSecs() == d2.deadlineNSecs();
115 
117  return d1.deadlineNSecs() != d2.deadlineNSecs();
119 
121  return d1.deadlineNSecs() < d2.deadlineNSecs();
123 
125  return d1.deadlineNSecs() <= d2.deadlineNSecs();
127 
129  return d1.deadlineNSecs() > d2.deadlineNSecs();
131 
133  return d1.deadlineNSecs() >= d2.deadlineNSecs();
The QDeadlineTimer class marks a deadline in the future.
static QDeadlineTimer current(Qt::TimerType timerType=Qt::CoarseTimer) noexcept
qint64 deadline() const noexcept Q_DECL_PURE_FUNCTION
bool hasExpired() const noexcept
qint64 remainingTime() const noexcept
void setRemainingTime(qint64 msecs, Qt::TimerType type=Qt::CoarseTimer) noexcept
qint64 deadlineNSecs() const noexcept Q_DECL_PURE_FUNCTION
bool tryLock(int timeout=0) noexcept
Definition: qmutex.h:291
std::chrono::milliseconds ms
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld cleanup[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld SRC pixld MASK if DST_R else pixld DST_R endif if src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head if pixblock_size cache_preload_simple endif process_pixblock_tail pixinterleave dst_w_basereg irp if pixblock_size chunk_size tst beq if DST_W else pixst DST_W else mov ORIG_W endif add lsl if lsl endif if lsl endif lsl endif lsl endif lsl endif subs mov DST_W if regs_shortage str endif bge start_of_loop_label endm macro generate_composite_function
long long qint64
Definition: qglobal.h:298
GLdouble s
[6]
Definition: qopenglext.h:235
device waitForReadyRead(deadline)
Q_ASSERT(deadline==now+1s)
void executeOperation(int msecs)
[0]
QDeadlineTimer deadline(30s)
QDate d1(1995, 5, 17)
[0]
QDate d2(1995, 5, 20)
QMutex mutex