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
VideoLAN
medialibrary
Commits
433593c5
Commit
433593c5
authored
Feb 14, 2022
by
Hugo Beauzée-Luyssen
Browse files
parser: Tolerate late completing tasks after flushing
parent
e93649ab
Pipeline
#190323
passed with stage
in 1 minute and 10 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/parser/Parser.cpp
View file @
433593c5
...
...
@@ -45,6 +45,7 @@ Parser::Parser( MediaLibrary* ml, FsHolder* fsHolder )
,
m_callback
(
nullptr
)
,
m_opScheduled
(
0
)
,
m_opDone
(
0
)
,
m_flushed
(
false
)
,
m_completionSignaled
(
false
)
{
}
...
...
@@ -69,6 +70,7 @@ void Parser::parse( std::shared_ptr<Task> task )
{
std
::
lock_guard
<
compat
::
Mutex
>
lock
{
m_mutex
};
m_opScheduled
+=
1
;
m_flushed
=
false
;
updateStats
();
}
m_serviceWorkers
[
0
]
->
parse
(
std
::
move
(
task
)
);
...
...
@@ -133,6 +135,7 @@ void Parser::flush()
std
::
lock_guard
<
compat
::
Mutex
>
lock
{
m_mutex
};
m_opDone
=
0
;
m_opScheduled
=
0
;
m_flushed
=
true
;
}
void
Parser
::
rescan
()
...
...
@@ -157,6 +160,7 @@ void Parser::restore()
{
std
::
lock_guard
<
compat
::
Mutex
>
lock
{
m_mutex
};
m_opScheduled
+=
tasks
.
size
();
m_flushed
=
false
;
updateStats
();
}
m_serviceWorkers
[
0
]
->
parse
(
std
::
move
(
tasks
)
);
...
...
@@ -199,7 +203,14 @@ void Parser::updateStats()
{
if
(
m_callback
==
nullptr
)
return
;
assert
(
m_opScheduled
>=
m_opDone
);
if
(
m_opScheduled
<
m_opDone
)
{
/* Tolerate completing tasks after a flush */
if
(
m_flushed
==
true
)
m_opDone
=
m_opScheduled
;
else
assert
(
!
"Unexpected completed task"
);
}
/*
* We don't want to spam the callback receiver each time we're done parsing
* an item, however we must signal progress when:
...
...
src/parser/Parser.h
View file @
433593c5
...
...
@@ -104,6 +104,7 @@ private:
IMediaLibraryCb
*
m_callback
;
uint32_t
m_opScheduled
;
uint32_t
m_opDone
;
bool
m_flushed
;
/* Helper flag to handle late completing tasks */
bool
m_completionSignaled
;
};
...
...
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