summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/osx/osxbtgcdtimer.mm
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2019-02-11 08:21:47 +0100
committerAlex Blasche <alexander.blasche@qt.io>2019-02-11 08:21:58 +0100
commit56c5b16dc1a394c72a004b71a9f5364059630d6c (patch)
tree7fc631b270636d42449871c0c894b9a5998821d9 /src/bluetooth/osx/osxbtgcdtimer.mm
parentc3820b3d04aca98ee4e0d5eb85b23819c039532f (diff)
parentcd2f90d9157199ebadcf182a471f264a619fd521 (diff)
Merge remote-tracking branch 'gerrit/dev' into wip/win
Diffstat (limited to 'src/bluetooth/osx/osxbtgcdtimer.mm')
-rw-r--r--src/bluetooth/osx/osxbtgcdtimer.mm41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/bluetooth/osx/osxbtgcdtimer.mm b/src/bluetooth/osx/osxbtgcdtimer.mm
index 095f8680..9663ca93 100644
--- a/src/bluetooth/osx/osxbtgcdtimer.mm
+++ b/src/bluetooth/osx/osxbtgcdtimer.mm
@@ -44,7 +44,23 @@
#include <algorithm>
-@implementation QT_MANGLE_NAMESPACE(OSXBTGCDTimer)
+QT_USE_NAMESPACE
+using namespace OSXBluetooth;
+
+@implementation QT_MANGLE_NAMESPACE(OSXBTGCDTimer) {
+@private
+ qint64 timeoutMS;
+ qint64 timeoutStepMS;
+
+ // Optional:
+ id objectUnderWatch;
+ OperationTimeout timeoutType;
+
+ QElapsedTimer timer;
+ id<QT_MANGLE_NAMESPACE(GCDTimerDelegate)> timeoutHandler;
+
+ bool cancelled;
+}
- (instancetype)initWithDelegate:(id<QT_MANGLE_NAMESPACE(GCDTimerDelegate)>)delegate
{
@@ -52,11 +68,19 @@
timeoutHandler = delegate;
timeoutMS = 0;
timeoutStepMS = 0;
+ objectUnderWatch = nil;
+ timeoutType = OperationTimeout::none;
cancelled = false;
}
return self;
}
+- (void)watchAfter:(id)object withTimeoutType:(OperationTimeout)type
+{
+ objectUnderWatch = object;
+ timeoutType = type;
+}
+
- (void)startWithTimeout:(qint64)ms step:(qint64)stepMS
{
Q_ASSERT(!timeoutMS && !timeoutStepMS);
@@ -86,9 +110,8 @@
const qint64 elapsed = timer.elapsed();
if (elapsed >= timeoutMS) {
- [timeoutHandler timeout];
+ [timeoutHandler timeout:self];
} else {
- using namespace QT_PREPEND_NAMESPACE(OSXBluetooth);
// Re-schedule:
dispatch_queue_t leQueue(qt_LE_queue());
Q_ASSERT(leQueue);
@@ -106,6 +129,18 @@
{
cancelled = true;
timeoutHandler = nil;
+ objectUnderWatch = nil;
+ timeoutType = OperationTimeout::none;
+}
+
+- (id)objectUnderWatch
+{
+ return objectUnderWatch;
+}
+
+- (OperationTimeout)timeoutType
+{
+ return timeoutType;
}
@end