pEpObjCAdapter/PEPPassphraseCache.m
branchIOSAD-172
changeset 1476 388741294076
parent 1475 cf82c13266ac
child 1477 5cb57fd85d00
     1.1 --- a/pEpObjCAdapter/PEPPassphraseCache.m	Fri Jun 26 16:54:34 2020 +0200
     1.2 +++ b/pEpObjCAdapter/PEPPassphraseCache.m	Fri Jun 26 16:54:34 2020 +0200
     1.3 @@ -20,7 +20,7 @@
     1.4  
     1.5  @property (nonatomic) dispatch_queue_t queue;
     1.6  @property (nonatomic) NSMutableArray<PEPPassphraseCacheEntry *> *mutablePassphrases;
     1.7 -@property (nonatomic) NSTimer *checkExpiryTimer;
     1.8 +@property (nonatomic) dispatch_source_t timer;
     1.9  
    1.10  @end
    1.11  
    1.12 @@ -38,21 +38,20 @@
    1.13  
    1.14          // we have a strong reference to the timer, but the timer doesn't have one to us
    1.15          typeof(self) __weak weakSelf = self;
    1.16 -        _checkExpiryTimer = [NSTimer
    1.17 -                             scheduledTimerWithTimeInterval:checkExpiryInterval
    1.18 -                             repeats:YES
    1.19 -                             block:^(NSTimer *timer) {
    1.20 +
    1.21 +        _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _queue);
    1.22 +        dispatch_source_set_timer(_timer,
    1.23 +                                  DISPATCH_TIME_NOW,
    1.24 +                                  checkExpiryInterval * NSEC_PER_SEC,
    1.25 +                                  checkExpiryInterval / 10 * NSEC_PER_SEC);
    1.26 +        dispatch_source_set_event_handler(_timer, ^{
    1.27              [weakSelf removeStaleEntries];
    1.28 -        }];
    1.29 +        });
    1.30 +        dispatch_resume(_timer);
    1.31      }
    1.32      return self;
    1.33  }
    1.34  
    1.35 -- (void)dealloc
    1.36 -{
    1.37 -    [_checkExpiryTimer invalidate];
    1.38 -}
    1.39 -
    1.40  /// Public constructor with default values.
    1.41  - (instancetype)init
    1.42  {