[vlc-devel] commit: Win32: fix previous commit plus small optimization ( Rémi Denis-Courmont )
git version control
git at videolan.org
Wed Dec 30 15:08:53 CET 2009
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Dec 30 16:08:07 2009 +0200| [aac948900ac88211f6a967bba1945dc0cd55b6b6] | committer: Rémi Denis-Courmont
Win32: fix previous commit plus small optimization
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=aac948900ac88211f6a967bba1945dc0cd55b6b6
---
include/vlc_threads.h | 8 ++++++--
src/misc/w32thread.c | 9 +++++++--
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index 65a4eb4..da892ac 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -127,11 +127,15 @@ typedef struct
bool dynamic;
union
{
- bool locked;
+ struct
+ {
+ bool locked;
+ unsigned long contention;
+ };
CRITICAL_SECTION mutex;
};
} vlc_mutex_t;
-#define VLC_STATIC_MUTEX { false, { false } }
+#define VLC_STATIC_MUTEX { false, { { false, 0 } } }
typedef HANDLE vlc_cond_t;
typedef HANDLE vlc_sem_t;
diff --git a/src/misc/w32thread.c b/src/misc/w32thread.c
index f4e247c..349dd81 100644
--- a/src/misc/w32thread.c
+++ b/src/misc/w32thread.c
@@ -195,7 +195,11 @@ void vlc_mutex_lock (vlc_mutex_t *p_mutex)
vlc_mutex_lock (&super_mutex);
while (p_mutex->locked)
- vlc_cond_wait (&super_mutex, &super_variable);
+ {
+ p_mutex->contention++;
+ vlc_cond_wait (&super_variable, &super_mutex);
+ p_mutex->contention--;
+ }
p_mutex->locked = true;
vlc_mutex_unlock (&super_mutex);
return;
@@ -233,7 +237,8 @@ void vlc_mutex_unlock (vlc_mutex_t *p_mutex)
vlc_mutex_lock (&super_mutex);
assert (p_mutex->locked);
p_mutex->locked = false;
- vlc_cond_signal (&super_variable);
+ if (p_mutex->contention)
+ vlc_cond_broadcast (&super_variable);
vlc_mutex_unlock (&super_mutex);
return;
}
More information about the vlc-devel
mailing list