diff options
Diffstat (limited to 'src/thread_null.c')
| -rw-r--r-- | src/thread_null.c | 280 |
1 files changed, 251 insertions, 29 deletions
diff --git a/src/thread_null.c b/src/thread_null.c index af73fd6..25d8a88 100644 --- a/src/thread_null.c +++ b/src/thread_null.c @@ -1,116 +1,300 @@ #include <bh/internal/thread.h> -int bh_thread_init(bh_thread_t *thread, - bh_task_t *task) +/** + * \ingroup thread + * \{ + */ + +/** + * Creates the thread object with the given \a task. + * + * \warning This function can be implemented either as a macro or as a function. + * + * \param task Pointer to the task object + * + * \return On success, returns the pointer to the new queue object. + * \return On failure, returns a null pointer. + */ +bh_thread_t *bh_thread_new(bh_task_t *task) { - (void)thread; (void)task; - return -1; + return NULL; } -bh_thread_t *bh_thread_new(bh_task_t *task) +/** + * Initializes the \a thread object with the given \a task. + * + * \warning This is an internal function. + * \warning This function can be implemented either as a macro or as a function. + * + * \param thread Pointer to the thread object + * \param task Pointer to the task object + * + * \return On success, returns zero. + * \return On failure, returns error code. + */ +int bh_thread_init(bh_thread_t *thread, + bh_task_t *task) { + (void)thread; (void)task; - return NULL; + return BH_NO_IMPL; } +/** + * Joins the \a thread. + * + * If thread was created with bh_thread_new, this function also frees the \a + * thread object. + * + * \param thread Pointer to the thread object + * + * \return On success, returns zero. + * \return On failure, returns error code. + */ int bh_thread_join(bh_thread_t *thread) { (void)thread; - return -1; + return BH_NO_IMPL; } +/** + * Detaches the \a thread. + * + * If thread was created with bh_thread_new, this function also frees the \a + * thread object. + * + * \param thread Pointer to the thread object + * + * \return On success, returns zero. + * \return On failure, returns error code. + */ int bh_thread_detach(bh_thread_t *thread) { (void)thread; - return -1; + return BH_NO_IMPL; } +/** + * Initializes the \a mutex object. + * + * \warning This is an internal function. + * + * \param mutex Pointer to the mutex object + * + * \return On success, returns zero. + * \return On failure, returns error code. + */ int bh_mutex_init(bh_mutex_t *mutex) { (void)mutex; - return -1; + return BH_NO_IMPL; } +/** + * Destroyes the \a mutex object. + * + * \param mutex Pointer to the mutex object + * + * \warning This is an internal function. + */ void bh_mutex_destroy(bh_mutex_t *mutex) { (void)mutex; } +/** + * Locks the \a mutex object. + * + * \param mutex Pointer to the mutex object + * + * \return On success, returns zero. + * \return On failure, returns error code. + */ int bh_mutex_lock(bh_mutex_t *mutex) { (void)mutex; - return -1; + return BH_NO_IMPL; } +/** + * Tries to lock the \a mutex object. + * + * \param mutex Pointer to the mutex object + * + * \return On success, returns zero. + * \return On failure, returns error code. + */ int bh_mutex_try_lock(bh_mutex_t *mutex) { (void)mutex; - return -1; + return BH_NO_IMPL; } +/** + * Unlocks the \a mutex object. + * + * \param mutex Pointer to the mutex object + * + * \return On success, returns zero. + * \return On failure, returns error code. + */ int bh_mutex_unlock(bh_mutex_t *mutex) { (void)mutex; - return -1; + return BH_NO_IMPL; } +/** + * Initilizes the \a semaphore object with specified \a count value. + * + * \warning This is an internal function. + * + * \param semaphore Pointer to the semaphore object + * \param count Initial semaphore value + * + * \return On success, returns zero. + * \return On failure, returns error code. + * + * \note Guranteed maximum \a count value is 32767. + */ int bh_semaphore_init(bh_semaphore_t *semaphore, int count) { (void)semaphore; (void)count; - return -1; + return BH_NO_IMPL; } +/** + * Destroyes the \a semaphore object. + * + * \warning This is an internal function. + * + * \param semaphore Pointer to the semaphore object + */ void bh_semaphore_destroy(bh_semaphore_t *semaphore) { (void)semaphore; } +/** + * Posts (increases value of) the \a semaphore. + * + * \param semaphore Pointer to the semaphore object + * + * \return On success, returns zero. + * \return On failure, returns error code. + */ int bh_semaphore_post(bh_semaphore_t *semaphore) { (void)semaphore; - return -1; + return BH_NO_IMPL; } +/** + * Waits (decreases value of) the \a semaphore. + * + * \param semaphore Pointer to the semaphore object + * + * \return On success, returns zero. + * \return On failure, returns error code. + */ int bh_semaphore_wait(bh_semaphore_t *semaphore) { (void)semaphore; - return -1; + return BH_NO_IMPL; } +/** + * Waits (decreases value of) the \a semaphore for the specified \a timeout + * amount of milliseconds. + * + * \param semaphore Pointer to the semaphore object + * \param timeout Number of milliseconds to wait for + * + * \return On success, returns zero. + * \return On failure or timeout, returns error code. + */ int bh_semaphore_wait_for(bh_semaphore_t *semaphore, unsigned long timeout) { (void)semaphore; - return -1; + return BH_NO_IMPL; } +/** + * Tries to waits (decrease value of) the \a semaphore. + * + * \param semaphore Pointer to the semaphore object + * + * \return On success, returns zero. + * \return On failure, returns error code. + */ int bh_semaphore_try_wait(bh_semaphore_t *semaphore) { (void)semaphore; - return -1; + return BH_NO_IMPL; } +/** + * Initializes the condition variable object \a cond. + * + * \warning This is an internal function. + * + * \param cond Pointer to the condition variable + * + * \return On success, returns zero. + * \return On failure, returns error code. + */ int bh_cond_init(bh_cond_t *cond) { (void)cond; - return -1; + return BH_NO_IMPL; } +/** + * Destroyes the condition variable object \a cond. + * + * \param cond Pointer to the condition variable object + * + * \return On success, returns zero. + * \return On failure, returns error code. + * + * \warning This is an internal function. + */ void bh_cond_destroy(bh_cond_t *cond) { (void)cond; } +/** + * Waits on the condition variable \a cond with specified \a mutex. + * + * \param cond Pointer to the condition variable object + * \param mutex Pointer to the mutex object + * + * \return On success, returns zero. + * \return ON failure, returns error code. + */ int bh_cond_wait(bh_cond_t *cond, bh_mutex_t *mutex) { (void)cond; (void)mutex; - return -1; + return BH_NO_IMPL; } +/** + * Waits on the condition variable \a cond with specified \a mutex for the + * specified \a timeout amount of milliseconds. + * + * \param cond Pointer to the condition variable object + * \param mutex Pointer to the mutex object + * \param timeout Number of milliseconds to wait for + * + * \return On success, returns zero. + * \return On failure or timeout, returns error code. + */ int bh_cond_wait_for(bh_cond_t *cond, bh_mutex_t *mutex, unsigned long timeout) @@ -118,33 +302,71 @@ int bh_cond_wait_for(bh_cond_t *cond, (void)cond; (void)mutex; (void)timeout; - return -1; + return BH_NO_IMPL; } +/** + * Signals (notifies) one waiting thread on the condition variable \a cond. + * + * \param cond Pointer to the condition variable object + * + * \return On success, returns zero. + * \return On failure, returns error code. + */ int bh_cond_signal(bh_cond_t *cond) { (void)cond; - return -1; + return BH_NO_IMPL; } +/** + * Signals (notifies) all waiting threads on the condition variable \a cond. + * + * \param cond Pointer to the condition variable object + * + * \return On success, returns zero. + * \return On failure, returns error code. + */ int bh_cond_broadcast(bh_cond_t *cond) { (void)cond; - return -1; + return BH_NO_IMPL; } -int bh_thread_pool_init(bh_thread_pool_t *pool, - size_t size) +/** + * Creates the thread pool object with specified \a size amount of threads. + * + * \param size Number of threads in the thread pool + * + * \return On success, returns pointer to the new thread pool object. + * \return On failure, returns null pointer. + */ +bh_thread_pool_t *bh_thread_pool_new(size_t size) { - (void)pool; (void)size; - return -1; + return NULL; } -bh_thread_pool_t *bh_thread_pool_new(size_t size) +/** + * Initilizes the thread \a pool object with specified \a size amount of + * threads. + * + * \warning This is an internal function. + * + * \param pool Pointer to the thread pool object + * \param size Number of threads in the thread pool + * + * \return On success, returns zero. + * \return On failure, returns error code. + */ +int bh_thread_pool_init(bh_thread_pool_t *pool, + size_t size) { + (void)pool; (void)size; - return NULL; + return BH_NO_IMPL; } - +/** + * \} + */
\ No newline at end of file |
