Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC
Manage
Activity
Members
Labels
Plan
Issues
4k
Issue boards
Milestones
Code
Merge requests
451
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC
Commits
6fdf44fd
Commit
6fdf44fd
authored
13 years ago
by
Rémi Denis-Courmont
Browse files
Options
Downloads
Patches
Plain Diff
Win32: use only one condition variable per R/W lock
parent
fd42ed01
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
configure.ac
+1
-1
1 addition, 1 deletion
configure.ac
include/vlc_threads.h
+2
-3
2 additions, 3 deletions
include/vlc_threads.h
src/win32/thread.c
+6
-10
6 additions, 10 deletions
src/win32/thread.c
with
9 additions
and
14 deletions
configure.ac
+
1
−
1
View file @
6fdf44fd
...
...
@@ -320,7 +320,7 @@ case "${host_os}" in
*mingw32* | *cygwin* | *wince* | *mingwce*)
AC_CHECK_TOOL(WINDRES, windres, :)
AC_CHECK_TOOL(OBJCOPY, objcopy, :)
AC_DEFINE([_WIN32_WINNT], 0x0
501
, [Define to '0x0
501
' for Windows
XP
APIs.])
AC_DEFINE([_WIN32_WINNT], 0x0
600
, [Define to '0x0
600
' for Windows
Vista
APIs.])
AC_DEFINE([_WIN32_IE], 0x0501, [Define to '0x0501' for IE 5.01 (and shell) APIs.])
case "${host_os}" in
...
...
This diff is collapsed.
Click to expand it.
include/vlc_threads.h
+
2
−
3
View file @
6fdf44fd
...
...
@@ -151,14 +151,13 @@ typedef HANDLE vlc_sem_t;
typedef
struct
{
vlc_mutex_t
mutex
;
vlc_cond_t
read_wait
;
vlc_cond_t
write_wait
;
vlc_cond_t
wait
;
unsigned
long
readers
;
unsigned
long
writers
;
DWORD
writer
;
}
vlc_rwlock_t
;
#define VLC_STATIC_RWLOCK \
{ VLC_STATIC_MUTEX, VLC_STATIC_COND,
VLC_STATIC_COND,
0, 0, 0 }
{ VLC_STATIC_MUTEX, VLC_STATIC_COND, 0, 0, 0 }
typedef
struct
vlc_threadvar
*
vlc_threadvar_t
;
typedef
struct
vlc_timer
*
vlc_timer_t
;
...
...
This diff is collapsed.
Click to expand it.
src/win32/thread.c
+
6
−
10
View file @
6fdf44fd
...
...
@@ -384,8 +384,7 @@ void vlc_sem_wait (vlc_sem_t *sem)
void
vlc_rwlock_init
(
vlc_rwlock_t
*
lock
)
{
vlc_mutex_init
(
&
lock
->
mutex
);
vlc_cond_init
(
&
lock
->
read_wait
);
vlc_cond_init
(
&
lock
->
write_wait
);
vlc_cond_init
(
&
lock
->
wait
);
lock
->
readers
=
0
;
/* active readers */
lock
->
writers
=
0
;
/* waiting writers */
lock
->
writer
=
0
;
/* ID of active writer */
...
...
@@ -393,8 +392,7 @@ void vlc_rwlock_init (vlc_rwlock_t *lock)
void
vlc_rwlock_destroy
(
vlc_rwlock_t
*
lock
)
{
vlc_cond_destroy
(
&
lock
->
read_wait
);
vlc_cond_destroy
(
&
lock
->
write_wait
);
vlc_cond_destroy
(
&
lock
->
wait
);
vlc_mutex_destroy
(
&
lock
->
mutex
);
}
...
...
@@ -411,7 +409,7 @@ void vlc_rwlock_rdlock (vlc_rwlock_t *lock)
while
(
lock
->
writer
!=
0
)
{
assert
(
lock
->
readers
==
0
);
vlc_cond_wait
(
&
lock
->
read_
wait
,
&
lock
->
mutex
);
vlc_cond_wait
(
&
lock
->
wait
,
&
lock
->
mutex
);
}
if
(
unlikely
(
lock
->
readers
==
ULONG_MAX
))
abort
();
...
...
@@ -426,7 +424,7 @@ static void vlc_rwlock_rdunlock (vlc_rwlock_t *lock)
/* If there are no readers left, wake up a writer. */
if
(
--
lock
->
readers
==
0
&&
lock
->
writers
>
0
)
vlc_cond_signal
(
&
lock
->
write_
wait
);
vlc_cond_signal
(
&
lock
->
wait
);
vlc_mutex_unlock
(
&
lock
->
mutex
);
}
...
...
@@ -438,7 +436,7 @@ void vlc_rwlock_wrlock (vlc_rwlock_t *lock)
lock
->
writers
++
;
/* Wait until nobody owns the lock in either way. */
while
((
lock
->
readers
>
0
)
||
(
lock
->
writer
!=
0
))
vlc_cond_wait
(
&
lock
->
write_
wait
,
&
lock
->
mutex
);
vlc_cond_wait
(
&
lock
->
wait
,
&
lock
->
mutex
);
lock
->
writers
--
;
assert
(
lock
->
writer
==
0
);
lock
->
writer
=
GetCurrentThreadId
();
...
...
@@ -453,9 +451,7 @@ static void vlc_rwlock_wrunlock (vlc_rwlock_t *lock)
lock
->
writer
=
0
;
/* Write unlock */
/* Let reader and writer compete. Scheduler decides who wins. */
if
(
lock
->
writers
>
0
)
vlc_cond_signal
(
&
lock
->
write_wait
);
vlc_cond_broadcast
(
&
lock
->
read_wait
);
vlc_cond_broadcast
(
&
lock
->
wait
);
vlc_mutex_unlock
(
&
lock
->
mutex
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment