]> git.sesse.net Git - vlc/blobdiff - src/misc/pthread.c
Read/write locks
[vlc] / src / misc / pthread.c
index 9264598250729010573c3053f81cbdb244950e90..14a48ad21be1f0037b115705b6f11b4dc2706701 100644 (file)
@@ -375,6 +375,51 @@ int vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
     return val;
 }
 
+/**
+ * Initializes a read/write lock.
+ */
+void vlc_rwlock_init (vlc_rwlock_t *lock)
+{
+    if (pthread_rwlock_init (lock, NULL))
+        abort ();
+}
+
+/**
+ * Destroys an initialized unused read/write lock.
+ */
+void vlc_rwlock_destroy (vlc_rwlock_t *lock)
+{
+    int val = pthread_rwlock_destroy (lock);
+    VLC_THREAD_ASSERT ("destroying R/W lock");
+}
+
+/**
+ * Acquires a read/write lock for reading. Recursion is allowed.
+ */
+void vlc_rwlock_rdlock (vlc_rwlock_t *lock)
+{
+    int val = pthread_rwlock_rdlock (lock);
+    VLC_THREAD_ASSERT ("acquiring R/W lock for reading");
+}
+
+/**
+ * Acquires a read/write lock for writing. Recursion is not allowed.
+ */
+void vlc_rwlock_wrlock (vlc_rwlock_t *lock)
+{
+    int val = pthread_rwlock_wrlock (lock);
+    VLC_THREAD_ASSERT ("acquiring R/W lock for writing");
+}
+
+/**
+ * Releases a read/write lock.
+ */
+void vlc_rwlock_unlock (vlc_rwlock_t *lock)
+{
+    int val = pthread_rwlock_unlock (lock);
+    VLC_THREAD_ASSERT ("releasing R/W lock");
+}
+
 /**
  * Allocates a thread-specific variable.
  * @param key where to store the thread-specific variable handle