Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
99a46209
Commit
99a46209
authored
Jan 28, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Win32: remove vlc_rwlock_t.writers - not really needed
parent
cc40da80
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
30 deletions
+7
-30
include/vlc_threads.h
include/vlc_threads.h
+2
-4
src/os2/thread.c
src/os2/thread.c
+2
-13
src/win32/thread.c
src/win32/thread.c
+3
-13
No files found.
include/vlc_threads.h
View file @
99a46209
...
...
@@ -166,11 +166,10 @@ typedef struct
vlc_mutex_t
mutex
;
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, 0, 0
, 0
}
{ VLC_STATIC_MUTEX, VLC_STATIC_COND, 0, 0 }
typedef
struct
vlc_threadvar
*
vlc_threadvar_t
;
typedef
struct
vlc_timer
*
vlc_timer_t
;
...
...
@@ -215,11 +214,10 @@ typedef struct
vlc_mutex_t
mutex
;
vlc_cond_t
wait
;
unsigned
long
readers
;
unsigned
long
writers
;
int
writer
;
}
vlc_rwlock_t
;
#define VLC_STATIC_RWLOCK \
{ VLC_STATIC_MUTEX, VLC_STATIC_COND, 0, 0
, 0
}
{ VLC_STATIC_MUTEX, VLC_STATIC_COND, 0, 0 }
typedef
struct
vlc_threadvar
*
vlc_threadvar_t
;
typedef
struct
vlc_timer
*
vlc_timer_t
;
...
...
src/os2/thread.c
View file @
99a46209
...
...
@@ -434,7 +434,6 @@ void vlc_rwlock_init (vlc_rwlock_t *lock)
vlc_mutex_init
(
&
lock
->
mutex
);
vlc_cond_init
(
&
lock
->
wait
);
lock
->
readers
=
0
;
/* active readers */
lock
->
writers
=
0
;
/* waiting or active writers */
lock
->
writer
=
0
;
/* ID of active writer */
}
...
...
@@ -447,13 +446,7 @@ void vlc_rwlock_destroy (vlc_rwlock_t *lock)
void
vlc_rwlock_rdlock
(
vlc_rwlock_t
*
lock
)
{
vlc_mutex_lock
(
&
lock
->
mutex
);
/* Recursive read-locking is allowed. With the infos available:
* - the loosest possible condition (no active writer) is:
* (lock->writer != 0)
* - the strictest possible condition is:
* (lock->writer != 0 || (lock->readers == 0 && lock->writers > 0))
* or (lock->readers == 0 && (lock->writer != 0 || lock->writers > 0))
*/
/* Recursive read-locking is allowed. */
while
(
lock
->
writer
!=
0
)
{
assert
(
lock
->
readers
==
0
);
...
...
@@ -471,7 +464,7 @@ static void vlc_rwlock_rdunlock (vlc_rwlock_t *lock)
assert
(
lock
->
readers
>
0
);
/* If there are no readers left, wake up a writer. */
if
(
--
lock
->
readers
==
0
&&
lock
->
writers
>
0
)
if
(
--
lock
->
readers
==
0
)
vlc_cond_signal
(
&
lock
->
wait
);
vlc_mutex_unlock
(
&
lock
->
mutex
);
}
...
...
@@ -479,13 +472,9 @@ static void vlc_rwlock_rdunlock (vlc_rwlock_t *lock)
void
vlc_rwlock_wrlock
(
vlc_rwlock_t
*
lock
)
{
vlc_mutex_lock
(
&
lock
->
mutex
);
if
(
unlikely
(
lock
->
writers
==
ULONG_MAX
))
abort
();
lock
->
writers
++
;
/* Wait until nobody owns the lock in either way. */
while
((
lock
->
readers
>
0
)
||
(
lock
->
writer
!=
0
))
vlc_cond_wait
(
&
lock
->
wait
,
&
lock
->
mutex
);
lock
->
writers
--
;
assert
(
lock
->
writer
==
0
);
lock
->
writer
=
_gettid
();
vlc_mutex_unlock
(
&
lock
->
mutex
);
...
...
src/win32/thread.c
View file @
99a46209
...
...
@@ -388,7 +388,6 @@ void vlc_rwlock_init (vlc_rwlock_t *lock)
vlc_mutex_init
(
&
lock
->
mutex
);
vlc_cond_init
(
&
lock
->
wait
);
lock
->
readers
=
0
;
/* active readers */
lock
->
writers
=
0
;
/* waiting writers */
lock
->
writer
=
0
;
/* ID of active writer */
}
...
...
@@ -401,13 +400,8 @@ void vlc_rwlock_destroy (vlc_rwlock_t *lock)
void
vlc_rwlock_rdlock
(
vlc_rwlock_t
*
lock
)
{
vlc_mutex_lock
(
&
lock
->
mutex
);
/* Recursive read-locking is allowed. With the infos available:
* - the loosest possible condition (no active writer) is:
* (lock->writer != 0)
* - the strictest possible condition is:
* (lock->writer != 0 || (lock->readers == 0 && lock->writers > 0))
* or (lock->readers == 0 && (lock->writer != 0 || lock->writers > 0))
*/
/* Recursive read-locking is allowed. We only need to ensure that there is
* no active writer. */
while
(
lock
->
writer
!=
0
)
{
assert
(
lock
->
readers
==
0
);
...
...
@@ -425,7 +419,7 @@ static void vlc_rwlock_rdunlock (vlc_rwlock_t *lock)
assert
(
lock
->
readers
>
0
);
/* If there are no readers left, wake up a writer. */
if
(
--
lock
->
readers
==
0
&&
lock
->
writers
>
0
)
if
(
--
lock
->
readers
==
0
)
vlc_cond_signal
(
&
lock
->
wait
);
vlc_mutex_unlock
(
&
lock
->
mutex
);
}
...
...
@@ -433,13 +427,9 @@ static void vlc_rwlock_rdunlock (vlc_rwlock_t *lock)
void
vlc_rwlock_wrlock
(
vlc_rwlock_t
*
lock
)
{
vlc_mutex_lock
(
&
lock
->
mutex
);
if
(
unlikely
(
lock
->
writers
==
ULONG_MAX
))
abort
();
lock
->
writers
++
;
/* Wait until nobody owns the lock in either way. */
while
((
lock
->
readers
>
0
)
||
(
lock
->
writer
!=
0
))
vlc_cond_wait
(
&
lock
->
wait
,
&
lock
->
mutex
);
lock
->
writers
--
;
assert
(
lock
->
writer
==
0
);
lock
->
writer
=
GetCurrentThreadId
();
vlc_mutex_unlock
(
&
lock
->
mutex
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment