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 e96bb50 commit a901e67
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
14 changes: 10 additions & 4 deletions YBTaskScheduler/YBTSQueue.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ @implementation YBTSQueue {
#pragma mark - life cycle

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

Expand All @@ -38,6 +38,14 @@ - (instancetype)init {
return self;
}

#pragma mark - private

- (void)clearTasks {
pthread_mutex_lock(&_lock);
_deque.clear();
pthread_mutex_unlock(&_lock);
}

#pragma mark - <YBTaskSchedulerStrategyProtocol>

- (BOOL)ybts_empty {
Expand Down Expand Up @@ -71,9 +79,7 @@ - (void)ybts_executeTask {
}

- (void)ybts_clearTasks {
pthread_mutex_lock(&_lock);
_deque.clear();
pthread_mutex_unlock(&_lock);
[self clearTasks];
}

@end
14 changes: 10 additions & 4 deletions YBTaskScheduler/YBTSStack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ @implementation YBTSStack {
#pragma mark - life cycle

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

Expand All @@ -38,6 +38,14 @@ - (instancetype)init {
return self;
}

#pragma mark - private

- (void)clearTasks {
pthread_mutex_lock(&_lock);
_deque.clear();
pthread_mutex_unlock(&_lock);
}

#pragma mark - <YBTaskSchedulerStrategyProtocol>

- (BOOL)ybts_empty {
Expand Down Expand Up @@ -71,9 +79,7 @@ - (void)ybts_executeTask {
}

- (void)ybts_clearTasks {
pthread_mutex_lock(&_lock);
_deque.clear();
pthread_mutex_unlock(&_lock);
[self clearTasks];
}

@end

0 comments on commit a901e67

Please sign in to comment.