Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
0c63632c
You need to sign in or sign up before continuing.
Commit
0c63632c
authored
Oct 17, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UpdateGlue: pass UpdateQueueItem around
Fixes a few kludges and avoids GLib allocation.
parent
b93523c0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
20 deletions
+16
-20
UpdateGlue.cxx
src/UpdateGlue.cxx
+16
-20
No files found.
src/UpdateGlue.cxx
View file @
0c63632c
...
...
@@ -36,8 +36,6 @@
#include "thread/Id.hxx"
#include "thread/Thread.hxx"
#include <glib.h>
#include <assert.h>
static
enum
update_progress
{
...
...
@@ -54,8 +52,7 @@ static const unsigned update_task_id_max = 1 << 15;
static
unsigned
update_task_id
;
/* XXX this flag is passed to update_task() */
static
bool
discard
;
static
UpdateQueueItem
next
;
unsigned
isUpdatingDB
(
void
)
...
...
@@ -64,16 +61,15 @@ isUpdatingDB(void)
}
static
void
update_task
(
void
*
_path
)
update_task
(
gcc_unused
void
*
ctx
)
{
const
char
*
path
=
(
const
char
*
)
_path
;
if
(
path
!=
NULL
&&
*
path
!=
0
)
FormatDebug
(
update_domain
,
"starting: %s"
,
path
);
if
(
!
next
.
path_utf8
.
empty
())
FormatDebug
(
update_domain
,
"starting: %s"
,
next
.
path_utf8
.
c_str
());
else
LogDebug
(
update_domain
,
"starting"
);
modified
=
update_walk
(
path
,
discard
);
modified
=
update_walk
(
next
.
path_utf8
.
c_str
(),
next
.
discard
);
if
(
modified
||
!
db_exists
())
{
Error
error
;
...
...
@@ -81,26 +77,28 @@ update_task(void *_path)
LogError
(
error
,
"Failed to save database"
);
}
if
(
path
!=
NULL
&&
*
path
!=
0
)
FormatDebug
(
update_domain
,
"finished: %s"
,
path
);
if
(
!
next
.
path_utf8
.
empty
())
FormatDebug
(
update_domain
,
"finished: %s"
,
next
.
path_utf8
.
c_str
());
else
LogDebug
(
update_domain
,
"finished"
);
g_free
(
_path
);
progress
=
UPDATE_PROGRESS_DONE
;
GlobalEvents
::
Emit
(
GlobalEvents
::
UPDATE
);
}
static
void
spawn_update_task
(
const
char
*
path
)
spawn_update_task
(
UpdateQueueItem
&&
i
)
{
assert
(
main_thread
.
IsInside
());
progress
=
UPDATE_PROGRESS_RUNNING
;
modified
=
false
;
next
=
std
::
move
(
i
);
Error
error
;
if
(
!
update_thread
.
Start
(
update_task
,
g_strdup
(
path
)
,
error
))
if
(
!
update_thread
.
Start
(
update_task
,
nullptr
,
error
))
FatalError
(
error
);
if
(
++
update_task_id
>
update_task_id_max
)
...
...
@@ -110,7 +108,7 @@ spawn_update_task(const char *path)
}
unsigned
update_enqueue
(
const
char
*
path
,
bool
_
discard
)
update_enqueue
(
const
char
*
path
,
bool
discard
)
{
assert
(
main_thread
.
IsInside
());
...
...
@@ -126,8 +124,7 @@ update_enqueue(const char *path, bool _discard)
return
next_task_id
>
update_task_id_max
?
1
:
next_task_id
;
}
discard
=
_discard
;
spawn_update_task
(
path
);
spawn_update_task
(
UpdateQueueItem
(
path
,
discard
));
idle_add
(
IDLE_UPDATE
);
...
...
@@ -152,8 +149,7 @@ static void update_finished_event(void)
auto
i
=
update_queue_shift
();
if
(
i
.
IsDefined
())
{
/* schedule the next path */
discard
=
i
.
discard
;
spawn_update_task
(
i
.
path_utf8
.
c_str
());
spawn_update_task
(
std
::
move
(
i
));
}
else
{
progress
=
UPDATE_PROGRESS_IDLE
;
...
...
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