-
Notifications
You must be signed in to change notification settings - Fork 2
/
ThreadPool.h
45 lines (34 loc) · 914 Bytes
/
ThreadPool.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
42
43
44
45
//
// ThreadPool 1.0
//
// Created by Kelp on 12/7/22.
// Copyright (c) 2012 Phate. All rights reserved.
//
#import <Foundation/Foundation.h>
@class ThreadPool;
#pragma mark - Enums
enum {
ThreadPoolQueue = 0,
ThreadPoolCancelBefore,
ThreadPoolCancelThis
};
typedef NSUInteger ThreadPoolType;
#pragma mark - Protocol
@protocol ThreadPoolDelegate
- (void)poolCleared:(ThreadPool *)threadPool;
@end
#pragma mark - ThreadPool
@interface ThreadPool : NSObject {
NSMutableArray *_poolQueue;
NSMutableArray *_poolExecute;
NSTimer *_timer;
}
@property int maxThreadNumber;
@property (strong) id<ThreadPoolDelegate> delegate;
@property (readonly) BOOL isPoolCleared;
+ (id)sharedInstance;
- (void)pushThread:(NSThread *)thread;
- (void)pushThread:(NSThread *)thread threadPoolType:(ThreadPoolType)threadPoolType;
- (void)cancelAllthreadsInExecutePool;
- (void)cancelAllThreads;
@end