@@ -19,15 +19,15 @@ FOUNDATION_EXPORT const unsigned char STNetTaskQueueVersionString[];
19
19
20
20
@protocol STNetTaskQueueHandler <NSObject >
21
21
22
- /*
22
+ /* *
23
23
STNetTaskQueue will call this method when a net task is added to queue and become ready to be excecuted.
24
24
25
25
@param netTaskQueue STNetTaskQueue The net task queue which is holding the net task.
26
26
@param task STNetTask The net task which is ready to be executed.
27
27
*/
28
28
- (void )netTaskQueue : (STNetTaskQueue *)netTaskQueue handleTask : (STNetTask *)task ;
29
29
30
- /*
30
+ /* *
31
31
STNetTaskQueue will call this method when a net task is cancelled and removed from net task queue.
32
32
Giving a chance to the handler to do a clean up for the cancelled net task.
33
33
@@ -36,7 +36,7 @@ FOUNDATION_EXPORT const unsigned char STNetTaskQueueVersionString[];
36
36
*/
37
37
- (void )netTaskQueue : (STNetTaskQueue *)netTaskQueue didCancelTask : (STNetTask *)task ;
38
38
39
- /*
39
+ /* *
40
40
STNetTaskQueue will call this method when the net task queue is deallocated.
41
41
42
42
@param netTaskQueue STNetTaskQueue The net task queue which is deallocated.
@@ -47,21 +47,23 @@ FOUNDATION_EXPORT const unsigned char STNetTaskQueueVersionString[];
47
47
48
48
@interface STNetTaskQueue : NSObject
49
49
50
- /* The STNetTaskQueueHandler which is used for handling the net tasks in queue. */
50
+ /* *
51
+ The STNetTaskQueueHandler which is used for handling the net tasks in queue.
52
+ */
51
53
@property (nonatomic , strong ) id <STNetTaskQueueHandler> handler;
52
54
53
- /*
55
+ /* *
54
56
Count of Max concurrent task in a queue.
55
57
If the number of unfinished tasks in queue hits the max count, upcoming task will be processed till one of the unfinished task is done.
56
58
*/
57
59
@property (nonatomic , assign ) NSUInteger maxConcurrentTasksCount;
58
60
59
- /*
61
+ /* *
60
62
A shared STNetTaskQueue instance.
61
63
*/
62
64
+ (instancetype )sharedQueue ;
63
65
64
- /*
66
+ /* *
65
67
Add a net task into the net task queue.
66
68
The net task may not be executed immediately depends on the "maxConcurrentTasksCount",
67
69
but the net task will be marked as "pending" anyway.
@@ -70,15 +72,15 @@ FOUNDATION_EXPORT const unsigned char STNetTaskQueueVersionString[];
70
72
*/
71
73
- (void )addTask : (STNetTask *)task ;
72
74
73
- /*
75
+ /* *
74
76
Cancel and remove the net task from queue.
75
77
If the net task is executing, it will be cancelled and remove from the queue without calling the "netTaskDidEnd" delegate method.
76
78
77
79
@param task STNetTask The net task to be cancelled and removed from the queue.
78
80
*/
79
81
- (void )cancelTask : (STNetTask *)task ;
80
82
81
- /*
83
+ /* *
82
84
This method should be called when the "handler" finish handling the net task successfully.
83
85
After "handler" called this method, the net task will be marked as "finished", set "pending" as "NO", and removed from the queue.
84
86
@@ -87,7 +89,7 @@ FOUNDATION_EXPORT const unsigned char STNetTaskQueueVersionString[];
87
89
*/
88
90
- (void )task : (STNetTask *)task didResponse : (id )response ;
89
91
90
- /*
92
+ /* *
91
93
This method should be caled when the "handler" finish handling the net task with error.
92
94
After "hadnler" called this method, the net task will be marked as "finished", set "pending" as "NO", and removed from the queue.
93
95
@@ -96,7 +98,7 @@ FOUNDATION_EXPORT const unsigned char STNetTaskQueueVersionString[];
96
98
*/
97
99
- (void )task : (STNetTask *)task didFailWithError : (NSError *)error ;
98
100
99
- /*
101
+ /* *
100
102
Add a net task delegate to "STNetTaskQueue" with uri of the net task,
101
103
it's a weak reference and duplicated delegate with same uri will be ignored.
102
104
@@ -105,7 +107,7 @@ FOUNDATION_EXPORT const unsigned char STNetTaskQueueVersionString[];
105
107
*/
106
108
- (void )addTaskDelegate : (id <STNetTaskDelegate>)delegate uri : (NSString *)uri ;
107
109
108
- /*
110
+ /* *
109
111
Add a net task delegate to "STNetTaskQueue" with class of net task,
110
112
it's a weak reference and duplicated delegate with same class will be ignored.
111
113
@@ -114,7 +116,7 @@ FOUNDATION_EXPORT const unsigned char STNetTaskQueueVersionString[];
114
116
*/
115
117
- (void )addTaskDelegate : (id <STNetTaskDelegate>)delegate class : (Class )clazz ;
116
118
117
- /*
119
+ /* *
118
120
Most of the times you don't need to remove net task delegate explicitly,
119
121
because "STNetTaskQueue" holds weak reference of each delegate.
120
122
0 commit comments