[vlc-devel] commit: Critical section are internally recursive ( Rémi Denis-Courmont )
git version control
git at videolan.org
Sat Oct 4 17:04:15 CEST 2008
vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Mon Sep 29 21:18:20 2008 +0300| [c74c5cb25cf5fd98205d1b2aabb25a7286f50d9e] | committer: Rémi Denis-Courmont
Critical section are internally recursive
Remove all this useless stuff of mine.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c74c5cb25cf5fd98205d1b2aabb25a7286f50d9e
---
include/vlc_threads.h | 3 ---
src/misc/threads.c | 38 ++------------------------------------
2 files changed, 2 insertions(+), 39 deletions(-)
diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index 00e5b18..4cd9827 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -119,9 +119,6 @@ typedef struct
typedef struct
{
CRITICAL_SECTION mutex;
- LONG owner;
- unsigned recursion;
- bool recursive;
}
vlc_mutex_t;
typedef HANDLE vlc_cond_t;
diff --git a/src/misc/threads.c b/src/misc/threads.c
index 72022d5..58a4cb1 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -247,8 +247,9 @@ int vlc_mutex_init( vlc_mutex_t *p_mutex )
return i_result;
#elif defined( WIN32 )
+ /* This creates a recursive mutex. This is OK as fast mutexes have
+ * no defined behavior in case of recursive locking. */
InitializeCriticalSection (&p_mutex->mutex);
- p_mutex->recursive = false;
return 0;
#endif
@@ -275,9 +276,6 @@ int vlc_mutex_init_recursive( vlc_mutex_t *p_mutex )
#elif defined( WIN32 )
InitializeCriticalSection( &p_mutex->mutex );
- p_mutex->owner = 0; /* the error value for GetThreadId()! */
- p_mutex->recursion = 0;
- p_mutex->recursive = true;
return 0;
#endif
@@ -317,24 +315,6 @@ void vlc_mutex_lock (vlc_mutex_t *p_mutex)
VLC_THREAD_ASSERT ("locking mutex");
#elif defined( WIN32 )
- if (p_mutex->recursive)
- {
- DWORD self = GetCurrentThreadId ();
-
- if ((DWORD)InterlockedCompareExchange (&p_mutex->owner, self,
- self) == self)
- { /* We already locked this recursive mutex */
- p_mutex->recursion++;
- return;
- }
-
- /* We need to lock this recursive mutex */
- EnterCriticalSection (&p_mutex->mutex);
- self = InterlockedExchange (&p_mutex->owner, self);
- assert (self == 0); /* no previous owner */
- return;
- }
- /* Non-recursive mutex */
EnterCriticalSection (&p_mutex->mutex);
#endif
@@ -352,18 +332,6 @@ void vlc_mutex_unlock (vlc_mutex_t *p_mutex)
VLC_THREAD_ASSERT ("unlocking mutex");
#elif defined( WIN32 )
- if (p_mutex->recursive)
- {
- if (p_mutex->recursion != 0)
- {
- p_mutex->recursion--;
- return; /* We still own this mutex */
- }
-
- /* We release the mutex */
- InterlockedExchange (&p_mutex->owner, 0);
- /* fall through */
- }
LeaveCriticalSection (&p_mutex->mutex);
#endif
@@ -504,7 +472,6 @@ void vlc_cond_wait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex)
#elif defined( WIN32 )
DWORD result;
- assert (!p_mutex->recursive);
do
{
vlc_testcancel ();
@@ -545,7 +512,6 @@ int vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
#elif defined( WIN32 )
DWORD result;
- assert (!p_mutex->recursive);
do
{
vlc_testcancel ();
More information about the vlc-devel
mailing list