Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
10a55883
Commit
10a55883
authored
Jun 10, 2015
by
KO Myung-Hun
Committed by
Rémi Denis-Courmont
Jun 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
os2: thread: support static condition variable
Signed-off-by:
Rémi Denis-Courmont
<
remi@remlab.net
>
parent
867024da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
14 deletions
+59
-14
src/os2/thread.c
src/os2/thread.c
+59
-14
No files found.
src/os2/thread.c
View file @
10a55883
...
...
@@ -132,6 +132,8 @@ static vlc_mutex_t super_mutex;
static
vlc_cond_t
super_variable
;
extern
vlc_rwlock_t
config_lock
;
static
void
vlc_static_cond_destroy_all
(
void
);
int
_CRT_init
(
void
);
void
_CRT_term
(
void
);
...
...
@@ -160,6 +162,7 @@ unsigned long _System _DLL_InitTerm(unsigned long hmod, unsigned long flag)
vlc_threadvar_delete
(
&
thread_key
);
vlc_cond_destroy
(
&
super_variable
);
vlc_mutex_destroy
(
&
super_mutex
);
vlc_static_cond_destroy_all
();
_CRT_term
();
...
...
@@ -272,6 +275,54 @@ static void vlc_cond_init_common (vlc_cond_t *p_condvar, unsigned clock)
p_condvar
->
clock
=
clock
;
}
typedef
struct
vlc_static_cond_t
vlc_static_cond_t
;
struct
vlc_static_cond_t
{
vlc_cond_t
condvar
;
vlc_static_cond_t
*
next
;
};
static
vlc_static_cond_t
*
static_condvar_start
=
NULL
;
static
void
vlc_static_cond_init
(
vlc_cond_t
*
p_condvar
)
{
vlc_mutex_lock
(
&
super_mutex
);
if
(
p_condvar
->
hev
==
NULLHANDLE
)
{
vlc_cond_init_common
(
p_condvar
,
p_condvar
->
clock
);
vlc_static_cond_t
*
new_static_condvar
;
new_static_condvar
=
malloc
(
sizeof
(
*
new_static_condvar
));
if
(
unlikely
(
!
new_static_condvar
))
abort
();
memcpy
(
&
new_static_condvar
->
condvar
,
p_condvar
,
sizeof
(
*
p_condvar
));
new_static_condvar
->
next
=
static_condvar_start
;
static_condvar_start
=
new_static_condvar
;
}
vlc_mutex_unlock
(
&
super_mutex
);
}
static
void
vlc_static_cond_destroy_all
(
void
)
{
vlc_static_cond_t
*
static_condvar
;
vlc_static_cond_t
*
static_condvar_next
;
for
(
static_condvar
=
static_condvar_start
;
static_condvar
;
static_condvar
=
static_condvar_next
)
{
static_condvar_next
=
static_condvar
->
next
;
vlc_cond_destroy
(
&
static_condvar
->
condvar
);
free
(
static_condvar
);
}
}
void
vlc_cond_init
(
vlc_cond_t
*
p_condvar
)
{
vlc_cond_init_common
(
p_condvar
,
CLOCK_MONOTONIC
);
...
...
@@ -290,8 +341,8 @@ void vlc_cond_destroy (vlc_cond_t *p_condvar)
void
vlc_cond_signal
(
vlc_cond_t
*
p_condvar
)
{
if
(
!
p_condvar
->
hev
)
return
;
if
(
p_condvar
->
hev
==
NULLHANDLE
)
vlc_static_cond_init
(
p_condvar
)
;
if
(
!
__atomic_cmpxchg32
(
&
p_condvar
->
waiters
,
0
,
0
))
{
...
...
@@ -319,8 +370,8 @@ void vlc_cond_signal (vlc_cond_t *p_condvar)
void
vlc_cond_broadcast
(
vlc_cond_t
*
p_condvar
)
{
if
(
!
p_condvar
->
hev
)
return
;
if
(
p_condvar
->
hev
==
NULLHANDLE
)
vlc_static_cond_init
(
p_condvar
)
;
while
(
!
__atomic_cmpxchg32
(
&
p_condvar
->
waiters
,
0
,
0
))
vlc_cond_signal
(
p_condvar
);
...
...
@@ -358,11 +409,8 @@ static int vlc_cond_wait_common (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
void
vlc_cond_wait
(
vlc_cond_t
*
p_condvar
,
vlc_mutex_t
*
p_mutex
)
{
if
(
!
p_condvar
->
hev
)
{
/* FIXME FIXME FIXME */
msleep
(
50000
);
return
;
}
if
(
p_condvar
->
hev
==
NULLHANDLE
)
vlc_static_cond_init
(
p_condvar
);
vlc_cond_wait_common
(
p_condvar
,
p_mutex
,
SEM_INDEFINITE_WAIT
);
}
...
...
@@ -372,11 +420,8 @@ int vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
{
ULONG
ulTimeout
;
if
(
!
p_condvar
->
hev
)
{
/* FIXME FIXME FIXME */
msleep
(
50000
);
return
0
;
}
if
(
p_condvar
->
hev
==
NULLHANDLE
)
vlc_static_cond_init
(
p_condvar
);
mtime_t
total
;
switch
(
p_condvar
->
clock
)
...
...
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