Skip to content

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
indulgeIn committed Jan 5, 2019
1 parent 7d136f5 commit ef42809
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
Binary file added File/YBTaskSchedulerP0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added File/YBTaskSchedulerUML.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions YBTaskScheduler.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Pod::Spec.new do |s|


s.name = "YBTaskScheduler"
s.version = "1.0"
s.version = "1.0.1"
s.summary = "iOS 任务调度器,为 CPU 和内存减负"
s.description = <<-DESC
主要用途:拆分主线程任务、删除无意义任务减轻 CPU 和内存的负担,任务的优先级调度实现特殊需求。
Expand All @@ -20,9 +20,9 @@ Pod::Spec.new do |s|

s.source = { :git => "https://github.com/indulgeIn/YBTaskScheduler.git", :tag => "#{s.version}" }

s.source_files = "YBTaskScheduler/**/*.{h,m}"
s.source_files = "YBTaskScheduler/**/*.{h,m,mm}"

s.frameworks = "Foundation"
s.libraries = 'c++.1'

s.requires_arc = true

Expand Down
21 changes: 16 additions & 5 deletions YBTaskScheduler/YBTSPriorityQueue.mm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ @implementation YBTSPriorityQueue {

#pragma mark - life cycle

- (void)dealloc {
[self clearTasks];
pthread_mutex_destroy(&_lock);
}

- (instancetype)init {
self = [super init];
if (self) {
Expand All @@ -54,6 +59,16 @@ - (instancetype)init {
return self;
}

#pragma mark - private

- (void)clearTasks {
pthread_mutex_lock(&_lock);
while (!_queue.empty()) {
_queue.pop();
}
pthread_mutex_unlock(&_lock);
}

#pragma mark - <YBTaskSchedulerStrategyProtocol>

- (BOOL)ybts_empty {
Expand Down Expand Up @@ -83,11 +98,7 @@ - (void)ybts_executeTask {
}

- (void)ybts_clearTasks {
pthread_mutex_lock(&_lock);
while (!_queue.empty()) {
_queue.pop();
}
pthread_mutex_unlock(&_lock);
[self clearTasks];
}


Expand Down
2 changes: 1 addition & 1 deletion YBTaskScheduler/YBTaskScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
@param task 包裹任务的 block
@param priority 优先级
*/
- (void)addTask:(YBTaskBlock)task priority:(YBTaskPriority)priority;;
- (void)addTask:(YBTaskBlock)task priority:(YBTaskPriority)priority;

/**
清空所有任务
Expand Down
4 changes: 2 additions & 2 deletions YBTaskSchedulerDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@
233C712F21E08D6900D2AE95 /* YBTaskScheduler */ = {
isa = PBXGroup;
children = (
233C713021E08D6900D2AE95 /* YBTaskScheduler+Internal.h */,
233C713121E08D6900D2AE95 /* YBTaskScheduler.h */,
233C713221E08D6900D2AE95 /* YBTaskScheduler.m */,
233C713021E08D6900D2AE95 /* YBTaskScheduler+Internal.h */,
233C713321E08D6900D2AE95 /* YBTaskSchedulerStrategyProtocol.h */,
233C713421E08D6900D2AE95 /* YBTaskSchedulerTypedef.h */,
233C713521E08D6900D2AE95 /* YBTSPriorityQueue.h */,
Expand Down Expand Up @@ -401,7 +401,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
ONLY_ACTIVE_ARCH = YES;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = yangbo.YBTaskSchedulerDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down

0 comments on commit ef42809

Please sign in to comment.