Remove whitespace
This commit is contained in:
@@ -44,13 +44,13 @@ bh_thread_pool_t *bh_thread_pool_new_base(size_t size,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @function bh_thread_new
|
* @function bh_thread_new
|
||||||
*
|
*
|
||||||
* @brief Create new thread.
|
* @brief Create new thread.
|
||||||
*
|
*
|
||||||
* @param task Thread task
|
* @param task Thread task
|
||||||
*
|
*
|
||||||
* @return Pointer to thread
|
* @return Pointer to thread
|
||||||
*
|
*
|
||||||
* @sa bh_thread_join, bh_thread_detach
|
* @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 pool Pointer to the thread pool
|
||||||
* @param size Amount of threads
|
* @param size Amount of threads
|
||||||
*
|
*
|
||||||
* @return Pointer to thread pool
|
* @return Pointer to thread pool
|
||||||
*
|
*
|
||||||
* @sa bh_thread_pool_add, bh_thread_pool_join, bh_thread_pool_free
|
* @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.
|
* @brief Join thread.
|
||||||
*
|
*
|
||||||
* @param thread Pointer to the thread
|
* @param thread Pointer to the thread
|
||||||
*
|
*
|
||||||
* @return 0 on success, non-zero otherwise
|
* @return 0 on success, non-zero otherwise
|
||||||
*
|
*
|
||||||
* @sa bh_thread_detach
|
* @sa bh_thread_detach
|
||||||
@@ -81,7 +81,7 @@ int bh_thread_join(bh_thread_t *thread);
|
|||||||
* @brief Detach thread.
|
* @brief Detach thread.
|
||||||
*
|
*
|
||||||
* @param thread Pointer to the thread
|
* @param thread Pointer to the thread
|
||||||
*
|
*
|
||||||
* @return 0 on success, non-zero otherwise
|
* @return 0 on success, non-zero otherwise
|
||||||
*
|
*
|
||||||
* @sa bh_thread_join
|
* @sa bh_thread_join
|
||||||
@@ -92,7 +92,7 @@ int bh_thread_detach(bh_thread_t *thread);
|
|||||||
* @brief Create mutex.
|
* @brief Create mutex.
|
||||||
*
|
*
|
||||||
* @return Pointer to the mutex
|
* @return Pointer to the mutex
|
||||||
*
|
*
|
||||||
* @sa bh_mutex_lock, bh_mutex_try_lock, bh_mutex_destroy
|
* @sa bh_mutex_lock, bh_mutex_try_lock, bh_mutex_destroy
|
||||||
*/
|
*/
|
||||||
bh_mutex_t *bh_mutex_new(void);
|
bh_mutex_t *bh_mutex_new(void);
|
||||||
@@ -108,10 +108,10 @@ void bh_mutex_free(bh_mutex_t *mutex);
|
|||||||
* @brief Lock mutex.
|
* @brief Lock mutex.
|
||||||
*
|
*
|
||||||
* @param mutex Pointer to the mutex
|
* @param mutex Pointer to the mutex
|
||||||
*
|
*
|
||||||
* @return 0 on success, non-zero otherwise
|
* @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
|
* released
|
||||||
*
|
*
|
||||||
* @sa bh_mutex_try_lock, bh_mutex_unlock
|
* @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.
|
* @brief Try to lock mutex.
|
||||||
*
|
*
|
||||||
* @param mutex Pointer to the 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
|
* error
|
||||||
*
|
*
|
||||||
* @sa bh_mutex_lock, bh_mutex_unlock
|
* @sa bh_mutex_lock, bh_mutex_unlock
|
||||||
@@ -134,7 +134,7 @@ int bh_mutex_try_lock(bh_mutex_t *mutex);
|
|||||||
* @brief Unlock mutex.
|
* @brief Unlock mutex.
|
||||||
*
|
*
|
||||||
* @param mutex Pointer to the mutex
|
* @param mutex Pointer to the mutex
|
||||||
*
|
*
|
||||||
* @return 0 on success, non-zero otherwise
|
* @return 0 on success, non-zero otherwise
|
||||||
*
|
*
|
||||||
* @sa bh_mutex_lock, bh_mutex_try_lock
|
* @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 cond Pointer to the condition variable
|
||||||
* @param mutex Pointer to the mutex
|
* @param mutex Pointer to the mutex
|
||||||
*
|
*
|
||||||
* @return 0 on success, non-zero otherwise
|
* @return 0 on success, non-zero otherwise
|
||||||
*
|
*
|
||||||
* @sa bh_cond_wait_for, bh_cond_signal, bh_cond_broadcast
|
* @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 cond Pointer to the conditional variable
|
||||||
* @param mutex Pointer to the mutex
|
* @param mutex Pointer to the mutex
|
||||||
* @param timeout Timeout in miliseconds
|
* @param timeout Timeout in miliseconds
|
||||||
*
|
*
|
||||||
* @return 0 on success, positive value on timeout, negative on error
|
* @return 0 on success, positive value on timeout, negative on error
|
||||||
*
|
*
|
||||||
* @sa bh_cond_wait, bh_cond_signal, bh_cond_broadcast
|
* @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.
|
* @brief Unblock (notify) thread.
|
||||||
*
|
*
|
||||||
* @param cond Pointer to the condition variable
|
* @param cond Pointer to the condition variable
|
||||||
*
|
*
|
||||||
* @return 0 on success, non-zero otherwise
|
* @return 0 on success, non-zero otherwise
|
||||||
*
|
*
|
||||||
* @sa bh_cond_broadcast, bh_cond_wait, bh_cond_wait_for
|
* @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.
|
* @brief Unblock all threads.
|
||||||
*
|
*
|
||||||
* @param cond Pointer to the conditional variable
|
* @param cond Pointer to the conditional variable
|
||||||
*
|
*
|
||||||
* @return 0 on success, non-zero otherwise
|
* @return 0 on success, non-zero otherwise
|
||||||
*
|
*
|
||||||
* @sa bh_cond_signal, bh_cond_wait, bh_cond_wait_for
|
* @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 pool Pointer to the thread pool
|
||||||
* @param func Task function
|
* @param func Task function
|
||||||
* @param data Task data
|
* @param data Task data
|
||||||
*
|
*
|
||||||
* @return 0 on success, non-zero otherwise
|
* @return 0 on success, non-zero otherwise
|
||||||
*
|
*
|
||||||
* @sa bh_thread_pool_join
|
* @sa bh_thread_pool_join
|
||||||
|
|||||||
2
main.c
2
main.c
@@ -51,7 +51,7 @@ int factor(int x)
|
|||||||
{
|
{
|
||||||
if (x < 2)
|
if (x < 2)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return factor(x - 1) + factor(x - 2);
|
return factor(x - 1) + factor(x - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -209,10 +209,10 @@ void bh_thread_pool_worker(void *arg)
|
|||||||
task->flags |= BH_THREAD_DONE;
|
task->flags |= BH_THREAD_DONE;
|
||||||
if (task->flags & BH_THREAD_CLEANUP)
|
if (task->flags & BH_THREAD_CLEANUP)
|
||||||
bh_task_free(task);
|
bh_task_free(task);
|
||||||
|
|
||||||
bh_mutex_lock(&pool->lock);
|
bh_mutex_lock(&pool->lock);
|
||||||
pool->active--;
|
pool->active--;
|
||||||
|
|
||||||
bh_mutex_unlock(&pool->lock);
|
bh_mutex_unlock(&pool->lock);
|
||||||
bh_cond_broadcast(&pool->done_task);
|
bh_cond_broadcast(&pool->done_task);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ static void *bh_thread_run(void *arg)
|
|||||||
|
|
||||||
if (task->flags & BH_THREAD_CLEANUP)
|
if (task->flags & BH_THREAD_CLEANUP)
|
||||||
bh_task_free(task);
|
bh_task_free(task);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ int bh_thread_pool_init(bh_thread_pool_t *pool,
|
|||||||
|
|
||||||
if (bh_cond_init(&pool->new_task))
|
if (bh_cond_init(&pool->new_task))
|
||||||
goto task_fail;
|
goto task_fail;
|
||||||
|
|
||||||
if (bh_cond_init(&pool->done_task))
|
if (bh_cond_init(&pool->done_task))
|
||||||
goto done_fail;
|
goto done_fail;
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ int bh_thread_pool_init(bh_thread_pool_t *pool,
|
|||||||
bh_queue_init(&pool->tasks);
|
bh_queue_init(&pool->tasks);
|
||||||
if (bh_queue_reserve(&pool->tasks, 64))
|
if (bh_queue_reserve(&pool->tasks, 64))
|
||||||
goto queue_fail;
|
goto queue_fail;
|
||||||
|
|
||||||
/* Initialize threads */
|
/* Initialize threads */
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
@@ -149,7 +149,7 @@ int bh_thread_pool_init(bh_thread_pool_t *pool,
|
|||||||
goto queue_fail;
|
goto queue_fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
queue_fail:
|
queue_fail:
|
||||||
|
|||||||
Reference in New Issue
Block a user