From a901e67e0b7756928f6196e6c4084302a1a61eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=B3=A2?= <1106355439@qq.com> Date: Sat, 5 Jan 2019 19:49:57 +0800 Subject: [PATCH] 1.0.1 --- YBTaskScheduler/YBTSQueue.mm | 14 ++++++++++---- YBTaskScheduler/YBTSStack.mm | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/YBTaskScheduler/YBTSQueue.mm b/YBTaskScheduler/YBTSQueue.mm index 1d86568..52dd187 100644 --- a/YBTaskScheduler/YBTSQueue.mm +++ b/YBTaskScheduler/YBTSQueue.mm @@ -22,7 +22,7 @@ @implementation YBTSQueue { #pragma mark - life cycle - (void)dealloc { - _deque.clear(); + [self clearTasks]; pthread_mutex_destroy(&_lock); } @@ -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 - - (BOOL)ybts_empty { @@ -71,9 +79,7 @@ - (void)ybts_executeTask { } - (void)ybts_clearTasks { - pthread_mutex_lock(&_lock); - _deque.clear(); - pthread_mutex_unlock(&_lock); + [self clearTasks]; } @end diff --git a/YBTaskScheduler/YBTSStack.mm b/YBTaskScheduler/YBTSStack.mm index 6835e06..86b93b0 100644 --- a/YBTaskScheduler/YBTSStack.mm +++ b/YBTaskScheduler/YBTSStack.mm @@ -22,7 +22,7 @@ @implementation YBTSStack { #pragma mark - life cycle - (void)dealloc { - _deque.clear(); + [self clearTasks]; pthread_mutex_destroy(&_lock); } @@ -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 - - (BOOL)ybts_empty { @@ -71,9 +79,7 @@ - (void)ybts_executeTask { } - (void)ybts_clearTasks { - pthread_mutex_lock(&_lock); - _deque.clear(); - pthread_mutex_unlock(&_lock); + [self clearTasks]; } @end