Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Romain Vimont
VLC
Commits
703ffde2
Commit
703ffde2
authored
Sep 17, 2018
by
Steve Lhomme
Browse files
background_worker: store the timeout in vlc_tick_t
parent
aabc784a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/misc/background_worker.c
View file @
703ffde2
...
...
@@ -33,7 +33,7 @@ struct task {
struct
vlc_list
node
;
void
*
id
;
/**< id associated with entity */
void
*
entity
;
/**< the entity to process */
in
t
timeout
;
/**< timeout duration in milliseconds */
vlc_tick_
t
timeout
;
/**< timeout duration in milliseconds */
};
struct
background_worker
;
...
...
@@ -73,7 +73,7 @@ static struct task *task_Create(struct background_worker *worker, void *id,
task
->
id
=
id
;
task
->
entity
=
entity
;
task
->
timeout
=
timeout
<
0
?
worker
->
conf
.
default_timeout
:
timeout
;
task
->
timeout
=
timeout
<
0
?
worker
->
conf
.
default_timeout
:
VLC_TICK_FROM_MS
(
timeout
)
;
worker
->
conf
.
pf_hold
(
task
->
entity
);
return
task
;
}
...
...
@@ -84,17 +84,17 @@ static void task_Destroy(struct background_worker *worker, struct task *task)
free
(
task
);
}
static
struct
task
*
QueueTake
(
struct
background_worker
*
worker
,
in
t
timeout
_ms
)
static
struct
task
*
QueueTake
(
struct
background_worker
*
worker
,
vlc_tick_
t
timeout
)
{
vlc_assert_locked
(
&
worker
->
lock
);
vlc_tick_t
deadline
=
vlc_tick_now
()
+
VLC_TICK_FROM_MS
(
timeout
_ms
)
;
bool
timeout
=
false
;
while
(
!
timeout
&&
!
worker
->
closing
&&
vlc_list_is_empty
(
&
worker
->
queue
))
timeout
=
vlc_cond_timedwait
(
&
worker
->
queue_wait
,
vlc_tick_t
deadline
=
vlc_tick_now
()
+
timeout
;
bool
has_
timeout
=
false
;
while
(
!
has_
timeout
&&
!
worker
->
closing
&&
vlc_list_is_empty
(
&
worker
->
queue
))
has_
timeout
=
vlc_cond_timedwait
(
&
worker
->
queue_wait
,
&
worker
->
lock
,
deadline
)
!=
0
;
if
(
worker
->
closing
||
timeout
)
if
(
worker
->
closing
||
has_
timeout
)
return
NULL
;
struct
task
*
task
=
vlc_list_first_entry_or_null
(
&
worker
->
queue
,
...
...
@@ -212,7 +212,7 @@ static void* Thread( void* data )
for
(;;)
{
vlc_mutex_lock
(
&
worker
->
lock
);
struct
task
*
task
=
QueueTake
(
worker
,
5000
);
struct
task
*
task
=
QueueTake
(
worker
,
VLC_TICK_FROM_SEC
(
5
)
);
if
(
!
task
)
{
vlc_mutex_unlock
(
&
worker
->
lock
);
...
...
Write
Preview
Supports
Markdown
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