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
3f9ad8e1
Commit
3f9ad8e1
authored
Feb 27, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/update/Service: allocate UpdateWalk dynamically
parent
1c772ef6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
19 deletions
+28
-19
Service.cxx
src/db/update/Service.cxx
+21
-7
Service.hxx
src/db/update/Service.hxx
+4
-2
UpdateSong.cxx
src/db/update/UpdateSong.cxx
+1
-1
Walk.cxx
src/db/update/Walk.cxx
+2
-1
Walk.hxx
src/db/update/Walk.hxx
+0
-8
No files found.
src/db/update/Service.cxx
View file @
3f9ad8e1
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include "config.h"
#include "config.h"
#include "Service.hxx"
#include "Service.hxx"
#include "Walk.hxx"
#include "UpdateDomain.hxx"
#include "UpdateDomain.hxx"
#include "db/DatabaseListener.hxx"
#include "db/DatabaseListener.hxx"
#include "db/plugins/simple/SimpleDatabasePlugin.hxx"
#include "db/plugins/simple/SimpleDatabasePlugin.hxx"
...
@@ -40,10 +41,12 @@
...
@@ -40,10 +41,12 @@
UpdateService
::
UpdateService
(
EventLoop
&
_loop
,
SimpleDatabase
&
_db
,
UpdateService
::
UpdateService
(
EventLoop
&
_loop
,
SimpleDatabase
&
_db
,
Storage
&
_storage
,
Storage
&
_storage
,
DatabaseListener
&
_listener
)
DatabaseListener
&
_listener
)
:
DeferredMonitor
(
_loop
),
db
(
_db
),
listener
(
_listener
),
:
DeferredMonitor
(
_loop
),
db
(
_db
),
storage
(
_storage
),
listener
(
_listener
),
progress
(
UPDATE_PROGRESS_IDLE
),
progress
(
UPDATE_PROGRESS_IDLE
),
update_task_id
(
0
),
update_task_id
(
0
),
walk
(
_loop
,
_listener
,
_storage
)
walk
(
nullptr
)
{
{
}
}
...
@@ -53,6 +56,8 @@ UpdateService::~UpdateService()
...
@@ -53,6 +56,8 @@ UpdateService::~UpdateService()
if
(
update_thread
.
IsDefined
())
if
(
update_thread
.
IsDefined
())
update_thread
.
Join
();
update_thread
.
Join
();
delete
walk
;
}
}
void
void
...
@@ -61,12 +66,16 @@ UpdateService::CancelAllAsync()
...
@@ -61,12 +66,16 @@ UpdateService::CancelAllAsync()
assert
(
GetEventLoop
().
IsInsideOrNull
());
assert
(
GetEventLoop
().
IsInsideOrNull
());
queue
.
Clear
();
queue
.
Clear
();
walk
.
Cancel
();
if
(
walk
!=
nullptr
)
walk
->
Cancel
();
}
}
inline
void
inline
void
UpdateService
::
Task
()
UpdateService
::
Task
()
{
{
assert
(
walk
!=
nullptr
);
if
(
!
next
.
path_utf8
.
empty
())
if
(
!
next
.
path_utf8
.
empty
())
FormatDebug
(
update_domain
,
"starting: %s"
,
FormatDebug
(
update_domain
,
"starting: %s"
,
next
.
path_utf8
.
c_str
());
next
.
path_utf8
.
c_str
());
...
@@ -75,8 +84,8 @@ UpdateService::Task()
...
@@ -75,8 +84,8 @@ UpdateService::Task()
SetThreadIdlePriority
();
SetThreadIdlePriority
();
modified
=
walk
.
Walk
(
*
db
.
GetRoot
(),
next
.
path_utf8
.
c_str
(),
modified
=
walk
->
Walk
(
*
db
.
GetRoot
(),
next
.
path_utf8
.
c_str
(),
next
.
discard
);
next
.
discard
);
if
(
modified
||
!
db
.
FileExists
())
{
if
(
modified
||
!
db
.
FileExists
())
{
Error
error
;
Error
error
;
...
@@ -105,13 +114,13 @@ void
...
@@ -105,13 +114,13 @@ void
UpdateService
::
StartThread
(
UpdateQueueItem
&&
i
)
UpdateService
::
StartThread
(
UpdateQueueItem
&&
i
)
{
{
assert
(
GetEventLoop
().
IsInsideOrNull
());
assert
(
GetEventLoop
().
IsInsideOrNull
());
assert
(
walk
==
nullptr
);
progress
=
UPDATE_PROGRESS_RUNNING
;
progress
=
UPDATE_PROGRESS_RUNNING
;
modified
=
false
;
modified
=
false
;
next
=
std
::
move
(
i
);
next
=
std
::
move
(
i
);
walk
=
new
UpdateWalk
(
GetEventLoop
(),
listener
,
storage
);
walk
.
Prepare
();
Error
error
;
Error
error
;
if
(
!
update_thread
.
Start
(
Task
,
this
,
error
))
if
(
!
update_thread
.
Start
(
Task
,
this
,
error
))
...
@@ -160,8 +169,13 @@ UpdateService::RunDeferred()
...
@@ -160,8 +169,13 @@ UpdateService::RunDeferred()
{
{
assert
(
progress
==
UPDATE_PROGRESS_DONE
);
assert
(
progress
==
UPDATE_PROGRESS_DONE
);
assert
(
next
.
IsDefined
());
assert
(
next
.
IsDefined
());
assert
(
walk
!=
nullptr
);
update_thread
.
Join
();
update_thread
.
Join
();
delete
walk
;
walk
=
nullptr
;
next
=
UpdateQueueItem
();
next
=
UpdateQueueItem
();
idle_add
(
IDLE_UPDATE
);
idle_add
(
IDLE_UPDATE
);
...
...
src/db/update/Service.hxx
View file @
3f9ad8e1
...
@@ -22,12 +22,13 @@
...
@@ -22,12 +22,13 @@
#include "check.h"
#include "check.h"
#include "Queue.hxx"
#include "Queue.hxx"
#include "Walk.hxx"
#include "event/DeferredMonitor.hxx"
#include "event/DeferredMonitor.hxx"
#include "thread/Thread.hxx"
#include "thread/Thread.hxx"
class
SimpleDatabase
;
class
SimpleDatabase
;
class
DatabaseListener
;
class
DatabaseListener
;
class
UpdateWalk
;
class
Storage
;
/**
/**
* This class manages the update queue and runs the update thread.
* This class manages the update queue and runs the update thread.
...
@@ -40,6 +41,7 @@ class UpdateService final : DeferredMonitor {
...
@@ -40,6 +41,7 @@ class UpdateService final : DeferredMonitor {
};
};
SimpleDatabase
&
db
;
SimpleDatabase
&
db
;
Storage
&
storage
;
DatabaseListener
&
listener
;
DatabaseListener
&
listener
;
...
@@ -57,7 +59,7 @@ class UpdateService final : DeferredMonitor {
...
@@ -57,7 +59,7 @@ class UpdateService final : DeferredMonitor {
UpdateQueueItem
next
;
UpdateQueueItem
next
;
UpdateWalk
walk
;
UpdateWalk
*
walk
;
public
:
public
:
UpdateService
(
EventLoop
&
_loop
,
SimpleDatabase
&
_db
,
UpdateService
(
EventLoop
&
_loop
,
SimpleDatabase
&
_db
,
...
...
src/db/update/UpdateSong.cxx
View file @
3f9ad8e1
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
*/
*/
#include "config.h"
/* must be first for large file support */
#include "config.h"
/* must be first for large file support */
#include "
Service
.hxx"
#include "
Walk
.hxx"
#include "UpdateIO.hxx"
#include "UpdateIO.hxx"
#include "UpdateDomain.hxx"
#include "UpdateDomain.hxx"
#include "db/DatabaseLock.hxx"
#include "db/DatabaseLock.hxx"
...
...
src/db/update/Walk.cxx
View file @
3f9ad8e1
...
@@ -51,7 +51,8 @@
...
@@ -51,7 +51,8 @@
UpdateWalk
::
UpdateWalk
(
EventLoop
&
_loop
,
DatabaseListener
&
_listener
,
UpdateWalk
::
UpdateWalk
(
EventLoop
&
_loop
,
DatabaseListener
&
_listener
,
Storage
&
_storage
)
Storage
&
_storage
)
:
storage
(
_storage
),
:
cancel
(
false
),
storage
(
_storage
),
editor
(
_loop
,
_listener
)
editor
(
_loop
,
_listener
)
{
{
#ifndef WIN32
#ifndef WIN32
...
...
src/db/update/Walk.hxx
View file @
3f9ad8e1
...
@@ -72,14 +72,6 @@ public:
...
@@ -72,14 +72,6 @@ public:
}
}
/**
/**
* Call from the main thread before starting the update
* thread.
*/
void
Prepare
()
{
cancel
=
false
;
}
/**
* Returns true if the database was modified.
* Returns true if the database was modified.
*/
*/
bool
Walk
(
Directory
&
root
,
const
char
*
path
,
bool
discard
);
bool
Walk
(
Directory
&
root
,
const
char
*
path
,
bool
discard
);
...
...
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