forked from robbiehanson/XMPPFramework
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathXMPPTimer.h
41 lines (35 loc) · 1.24 KB
/
XMPPTimer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#import <Foundation/Foundation.h>
/**
* This class is a simple wrapper around dispatch_source_t timers.
*
* The primary motivation for this is to allow timers to be stored in collections.
* But the class also makes it easier to code timers, as it simplifies the API.
**/
@interface XMPPTimer : NSObject
/**
* Creates an instance of a timer that will fire on the given queue.
* It will invoke the given event handler block when it fires.
**/
- (instancetype)initWithQueue:(dispatch_queue_t)queue eventHandler:(dispatch_block_t)block;
/**
* Starts the timer.
* It will first fire after the timeout.
* After that, it will continue to fire every interval.
*
* The interval is optional.
* If interval is zero (or negative), it will not use an interval (will only fire once after the timeout).
*
* This method can only be called once.
**/
- (void)startWithTimeout:(NSTimeInterval)timeout interval:(NSTimeInterval)interval;
/**
* Allows you to update an already started timer.
*
* The new timeout that you pass can be applied to 'now' or to the original start time of the timer.
**/
- (void)updateTimeout:(NSTimeInterval)timeout fromOriginalStartTime:(BOOL)useOriginalStartTime;
/**
* Cancels the timer so that it won't fire.
**/
- (void)cancel;
@end