CELIX-272: Add celix rw lock thread support
Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/a0926beb Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/a0926beb Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/a0926beb Branch: refs/heads/feature/CELIX-272_synchronization_service_registry Commit: a0926beb0b8c9af2ce9256537702fbecd8be3d4e Parents: e0231e5 Author: Pepijn Noltes <[email protected]> Authored: Wed Nov 11 13:21:06 2015 +0100 Committer: Pepijn Noltes <[email protected]> Committed: Wed Nov 11 13:21:06 2015 +0100 ---------------------------------------------------------------------- utils/private/src/celix_threads.c | 28 ++++++++++++++++++++++++++++ utils/public/include/celix_threads.h | 17 ++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/a0926beb/utils/private/src/celix_threads.c ---------------------------------------------------------------------- diff --git a/utils/private/src/celix_threads.c b/utils/private/src/celix_threads.c index d460dd7..bec374b 100644 --- a/utils/private/src/celix_threads.c +++ b/utils/private/src/celix_threads.c @@ -150,3 +150,31 @@ celix_status_t celixThreadCondition_broadcast(celix_thread_cond_t *cond) { celix_status_t celixThreadCondition_signal(celix_thread_cond_t *cond) { return pthread_cond_signal(cond); } + +celix_status_t celixThreadRwlock_create(celix_thread_rwlock_t *lock, celix_thread_rwlockattr_t *attr) { + return pthread_rwlock_init(lock, attr); +} + +celix_status_t celixThreadRwlock_destroy(celix_thread_rwlock_t *lock) { + return pthread_rwlock_destroy(lock); +} + +celix_status_t celixThreadRwlock_readLock(celix_thread_rwlock_t *lock) { + return pthread_rwlock_rdlock(lock); +} + +celix_status_t celixThreadRwlock_writeLock(celix_thread_rwlock_t *lock) { + return pthread_rwlock_wrlock(lock); +} + +celix_status_t celixThreadRwlock_unlock(celix_thread_rwlock_t *lock) { + return pthread_rwlock_unlock(lock); +} + +celix_status_t celixThreadRwlockAttr_create(celix_thread_rwlockattr_t *attr) { + return pthread_rwlockattr_init(attr); +} + +celix_status_t celixThreadRwlockAttr_destroy(celix_thread_rwlockattr_t *attr) { + return pthread_rwlockattr_destroy(attr); +} http://git-wip-us.apache.org/repos/asf/celix/blob/a0926beb/utils/public/include/celix_threads.h ---------------------------------------------------------------------- diff --git a/utils/public/include/celix_threads.h b/utils/public/include/celix_threads.h index c59edef..1e7a7ad 100644 --- a/utils/public/include/celix_threads.h +++ b/utils/public/include/celix_threads.h @@ -46,7 +46,6 @@ typedef void *(*celix_thread_start_t)(void*); static const celix_thread_t celix_thread_default = { 0, 0 }; - celix_status_t celixThread_create(celix_thread_t *new_thread, celix_thread_attr_t *attr, celix_thread_start_t func, void *data); void celixThread_exit(void *exitStatus); celix_status_t celixThread_detach(celix_thread_t thread); @@ -78,6 +77,21 @@ celix_status_t celixThreadMutexAttr_create(celix_thread_mutexattr_t *attr); celix_status_t celixThreadMutexAttr_destroy(celix_thread_mutexattr_t *attr); celix_status_t celixThreadMutexAttr_settype(celix_thread_mutexattr_t *attr, int type); +typedef pthread_rwlock_t celix_thread_rwlock_t; +typedef pthread_rwlockattr_t celix_thread_rwlockattr_t; + +celix_status_t celixThreadRwlock_create(celix_thread_rwlock_t *lock, celix_thread_rwlockattr_t *attr); + +celix_status_t celixThreadRwlock_destroy(celix_thread_rwlock_t *lock); +celix_status_t celixThreadRwlock_readLock(celix_thread_rwlock_t *lock); +celix_status_t celixThreadRwlock_writeLock(celix_thread_rwlock_t *lock); +celix_status_t celixThreadRwlock_unlock(celix_thread_rwlock_t *lock); + +celix_status_t celixThreadRwlockAttr_create(celix_thread_rwlockattr_t *attr); +celix_status_t celixThreadRwlockAttr_destroy(celix_thread_rwlockattr_t *attr); +//NOTE: No support yet for setting specific rw lock attributes + + typedef pthread_cond_t celix_thread_cond_t; typedef pthread_condattr_t celix_thread_condattr_t; @@ -87,4 +101,5 @@ celix_status_t celixThreadCondition_wait(celix_thread_cond_t *cond, celix_thread celix_status_t celixThreadCondition_broadcast(celix_thread_cond_t *cond); celix_status_t celixThreadCondition_signal(celix_thread_cond_t *cond); + #endif /* CELIX_THREADS_H_ */
