diff options
Diffstat (limited to 'async/src/async.cpp')
-rw-r--r-- | async/src/async.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/async/src/async.cpp b/async/src/async.cpp index e92d333..0e86a84 100644 --- a/async/src/async.cpp +++ b/async/src/async.cpp | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <QCoreApplication> | 20 | #include <QCoreApplication> |
21 | #include <QDebug> | 21 | #include <QDebug> |
22 | #include <QEventLoop> | 22 | #include <QEventLoop> |
23 | #include <QTimer> | ||
23 | 24 | ||
24 | using namespace Async; | 25 | using namespace Async; |
25 | 26 | ||
@@ -133,3 +134,15 @@ Job<void> Async::dowhile(ThenTask<bool> body) | |||
133 | }); | 134 | }); |
134 | } | 135 | } |
135 | 136 | ||
137 | Job<void> Async::wait(int delay) | ||
138 | { | ||
139 | auto timer = QSharedPointer<QTimer>::create(); | ||
140 | return Async::start<void>([timer, delay](Async::Future<void> &future) { | ||
141 | timer->setSingleShot(true); | ||
142 | QObject::connect(timer.data(), &QTimer::timeout, [&future]() { | ||
143 | future.setFinished(); | ||
144 | }); | ||
145 | timer->start(delay); | ||
146 | }); | ||
147 | } | ||
148 | |||