forked from mrnuku/util
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNUScheduler.h
More file actions
51 lines (41 loc) · 1.63 KB
/
NUScheduler.h
File metadata and controls
51 lines (41 loc) · 1.63 KB
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
42
43
44
45
46
47
48
49
50
51
//
// NUScheduler.h
// util
//
// Created by Bálint Róbert on 17/03/16.
// Copyright © 2016 mrnuku. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NUScheduler : NSObject
/**
The scheduler counter, what is incremented by the method of incerementCounter.
*/
@property (nonatomic, readonly) NSInteger counter;
/**
The scheduler counter limiter value. When the counter reaches this, the scheduler will fire a completion event to all action blocks.
Setting this value zero or less disables the counter event firing logic.
*/
@property (nonatomic) NSInteger counterLimit;
/**
The scheduler fallback timer interval controlls an internal timer, what will fire an event if the counter fails to increment in this specified time interval.
*/
@property (nonatomic) NSTimeInterval fallbackTimerInterval;
/**
Optionally used user supplemented data.
*/
@property (nonatomic, strong) id userData;
/**
The main event driving method. Call this to incerement the counter by one, when the limit value reached, this will fire the action blocks, on the same thread what this method called from.
*/
- (void)incerementCounter;
/**
Specify your action blocks with this method, and hold the returning reference strongly or nil it, if you want to disable the action block.
@param actionBlock The action block you want to register.
*/
- (id)addWeakActionBlock:(void (^)(NUScheduler *scheduler))actionBlock;
/**
Alternative method to disable your action block. (you can spare your strongly held reference for later use for example)
@param actionBlock The action block you want to de-register
*/
- (void)removeWeakActionBlock:(id)actionBlock;
@end