From ec499b6cfc3fe196757d4467ca044b5915198d45 Mon Sep 17 00:00:00 2001 From: Mikhail Romanko Date: Sun, 14 Apr 2024 22:38:00 +0300 Subject: Remove whitespace --- include/bh/thread.h | 34 +++++++++++++++++----------------- main.c | 2 +- src/thread.c | 4 ++-- src/thread_posix.c | 8 ++++---- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/bh/thread.h b/include/bh/thread.h index c8547ce..21edc1c 100644 --- a/include/bh/thread.h +++ b/include/bh/thread.h @@ -44,13 +44,13 @@ bh_thread_pool_t *bh_thread_pool_new_base(size_t size, /** * @function bh_thread_new - * + * * @brief Create new thread. * * @param task Thread task - * + * * @return Pointer to thread - * + * * @sa bh_thread_join, bh_thread_detach */ @@ -60,7 +60,7 @@ bh_thread_pool_t *bh_thread_pool_new_base(size_t size, * * @param pool Pointer to the thread pool * @param size Amount of threads - * + * * @return Pointer to thread pool * * @sa bh_thread_pool_add, bh_thread_pool_join, bh_thread_pool_free @@ -70,7 +70,7 @@ bh_thread_pool_t *bh_thread_pool_new_base(size_t size, * @brief Join thread. * * @param thread Pointer to the thread - * + * * @return 0 on success, non-zero otherwise * * @sa bh_thread_detach @@ -81,7 +81,7 @@ int bh_thread_join(bh_thread_t *thread); * @brief Detach thread. * * @param thread Pointer to the thread - * + * * @return 0 on success, non-zero otherwise * * @sa bh_thread_join @@ -92,7 +92,7 @@ int bh_thread_detach(bh_thread_t *thread); * @brief Create mutex. * * @return Pointer to the mutex - * + * * @sa bh_mutex_lock, bh_mutex_try_lock, bh_mutex_destroy */ bh_mutex_t *bh_mutex_new(void); @@ -108,10 +108,10 @@ void bh_mutex_free(bh_mutex_t *mutex); * @brief Lock mutex. * * @param mutex Pointer to the mutex - * + * * @return 0 on success, non-zero otherwise * - * @note Locking already locked mutex will block thread until mutex is + * @note Locking already locked mutex will block thread until mutex is * released * * @sa bh_mutex_try_lock, bh_mutex_unlock @@ -122,8 +122,8 @@ int bh_mutex_lock(bh_mutex_t *mutex); * @brief Try to lock mutex. * * @param mutex Pointer to the mutex - * - * @return 0 on success, positive value if mutex is locked, negative value on + * + * @return 0 on success, positive value if mutex is locked, negative value on * error * * @sa bh_mutex_lock, bh_mutex_unlock @@ -134,7 +134,7 @@ int bh_mutex_try_lock(bh_mutex_t *mutex); * @brief Unlock mutex. * * @param mutex Pointer to the mutex - * + * * @return 0 on success, non-zero otherwise * * @sa bh_mutex_lock, bh_mutex_try_lock @@ -160,7 +160,7 @@ void bh_cond_free(bh_cond_t *cond); * * @param cond Pointer to the condition variable * @param mutex Pointer to the mutex - * + * * @return 0 on success, non-zero otherwise * * @sa bh_cond_wait_for, bh_cond_signal, bh_cond_broadcast @@ -174,7 +174,7 @@ int bh_cond_wait(bh_cond_t *cond, * @param cond Pointer to the conditional variable * @param mutex Pointer to the mutex * @param timeout Timeout in miliseconds - * + * * @return 0 on success, positive value on timeout, negative on error * * @sa bh_cond_wait, bh_cond_signal, bh_cond_broadcast @@ -187,7 +187,7 @@ int bh_cond_wait_for(bh_cond_t *cond, * @brief Unblock (notify) thread. * * @param cond Pointer to the condition variable - * + * * @return 0 on success, non-zero otherwise * * @sa bh_cond_broadcast, bh_cond_wait, bh_cond_wait_for @@ -198,7 +198,7 @@ int bh_cond_signal(bh_cond_t *cond); * @brief Unblock all threads. * * @param cond Pointer to the conditional variable - * + * * @return 0 on success, non-zero otherwise * * @sa bh_cond_signal, bh_cond_wait, bh_cond_wait_for @@ -223,7 +223,7 @@ int bh_task_done(bh_task_t *task); * @param pool Pointer to the thread pool * @param func Task function * @param data Task data - * + * * @return 0 on success, non-zero otherwise * * @sa bh_thread_pool_join diff --git a/main.c b/main.c index e9880c5..fac0f2e 100644 --- a/main.c +++ b/main.c @@ -51,7 +51,7 @@ int factor(int x) { if (x < 2) return 1; - + return factor(x - 1) + factor(x - 2); } diff --git a/src/thread.c b/src/thread.c index 9620085..645dd0b 100644 --- a/src/thread.c +++ b/src/thread.c @@ -209,10 +209,10 @@ void bh_thread_pool_worker(void *arg) task->flags |= BH_THREAD_DONE; if (task->flags & BH_THREAD_CLEANUP) bh_task_free(task); - + bh_mutex_lock(&pool->lock); pool->active--; - + bh_mutex_unlock(&pool->lock); bh_cond_broadcast(&pool->done_task); } diff --git a/src/thread_posix.c b/src/thread_posix.c index a20bd57..2ed3ab8 100644 --- a/src/thread_posix.c +++ b/src/thread_posix.c @@ -13,7 +13,7 @@ static void *bh_thread_run(void *arg) if (task->flags & BH_THREAD_CLEANUP) bh_task_free(task); - + return NULL; } @@ -119,7 +119,7 @@ int bh_thread_pool_init(bh_thread_pool_t *pool, if (bh_cond_init(&pool->new_task)) goto task_fail; - + if (bh_cond_init(&pool->done_task)) goto done_fail; @@ -134,7 +134,7 @@ int bh_thread_pool_init(bh_thread_pool_t *pool, bh_queue_init(&pool->tasks); if (bh_queue_reserve(&pool->tasks, 64)) goto queue_fail; - + /* Initialize threads */ for (i = 0; i < size; i++) { @@ -149,7 +149,7 @@ int bh_thread_pool_init(bh_thread_pool_t *pool, goto queue_fail; } } - + return 0; queue_fail: -- cgit v1.2.3