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
e9ffcf98
Commit
e9ffcf98
authored
Oct 15, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Android: remove contention in vlc_cond_wait()
parent
3405b7da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
21 deletions
+54
-21
src/android/thread.c
src/android/thread.c
+54
-21
No files found.
src/android/thread.c
View file @
e9ffcf98
...
...
@@ -216,36 +216,65 @@ void vlc_cond_broadcast (vlc_cond_t *condvar)
void
vlc_cond_wait
(
vlc_cond_t
*
condvar
,
vlc_mutex_t
*
p_mutex
)
{
if
(
thread
)
{
vlc_testcancel
();
vlc_mutex_lock
(
&
thread
->
lock
);
thread
->
cond
=
&
condvar
->
cond
;
vlc_mutex_unlock
(
&
thread
->
lock
);
vlc_thread_t
th
=
thread
;
if
(
th
!=
NULL
)
{
vlc_testcancel
();
if
(
vlc_mutex_trylock
(
&
th
->
lock
)
==
0
)
{
th
->
cond
=
&
condvar
->
cond
;
vlc_mutex_unlock
(
&
th
->
lock
);
}
else
{
/* The lock is already held by another thread.
* => That other thread has just cancelled this one. */
vlc_testcancel
();
/* Cancellation did not occur even though this thread is cancelled.
* => Cancellation is disabled. */
th
=
NULL
;
}
}
int
val
=
pthread_cond_wait
(
&
condvar
->
cond
,
p_mutex
);
VLC_THREAD_ASSERT
(
"waiting on condition"
);
if
(
thread
)
{
vlc_mutex_lock
(
&
thread
->
lock
);
thread
->
cond
=
NULL
;
vlc_mutex_unlock
(
&
thread
->
lock
);
if
(
th
!=
NULL
)
{
if
(
vlc_mutex_trylock
(
&
th
->
lock
)
==
0
)
{
thread
->
cond
=
NULL
;
vlc_mutex_unlock
(
&
th
->
lock
);
}
/* Else: This thread was cancelled and is cancellable.
vlc_testcancel() will take of it right there: */
vlc_testcancel
();
}
VLC_THREAD_ASSERT
(
"waiting on condition"
);
}
int
vlc_cond_timedwait
(
vlc_cond_t
*
condvar
,
vlc_mutex_t
*
p_mutex
,
mtime_t
deadline
)
{
struct
timespec
ts
=
mtime_to_ts
(
deadline
);
vlc_thread_t
th
=
thread
;
int
(
*
cb
)(
pthread_cond_t
*
,
pthread_mutex_t
*
,
const
struct
timespec
*
);
if
(
thread
)
{
vlc_testcancel
();
vlc_mutex_lock
(
&
thread
->
lock
);
thread
->
cond
=
&
condvar
->
cond
;
vlc_mutex_unlock
(
&
thread
->
lock
);
if
(
th
!=
NULL
)
{
vlc_testcancel
();
if
(
vlc_mutex_trylock
(
&
th
->
lock
)
==
0
)
{
th
->
cond
=
&
condvar
->
cond
;
vlc_mutex_unlock
(
&
th
->
lock
);
}
else
{
/* The lock is already held by another thread.
* => That other thread has just cancelled this one. */
vlc_testcancel
();
/* Cancellation did not occur even though this thread is cancelled.
* => Cancellation is disabled. */
th
=
NULL
;
}
}
switch
(
condvar
->
clock
)
...
...
@@ -264,13 +293,17 @@ int vlc_cond_timedwait (vlc_cond_t *condvar, vlc_mutex_t *p_mutex,
if
(
val
!=
ETIMEDOUT
)
VLC_THREAD_ASSERT
(
"timed-waiting on condition"
);
if
(
thread
)
{
vlc_mutex_lock
(
&
thread
->
lock
);
thread
->
cond
=
NULL
;
vlc_mutex_unlock
(
&
thread
->
lock
);
if
(
th
!=
NULL
)
{
if
(
vlc_mutex_trylock
(
&
th
->
lock
)
==
0
)
{
thread
->
cond
=
NULL
;
vlc_mutex_unlock
(
&
th
->
lock
);
}
/* Else: This thread was cancelled and is cancellable.
vlc_testcancel() will take of it right there: */
vlc_testcancel
();
}
return
val
;
}
...
...
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