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
0240e754
Commit
0240e754
authored
Sep 05, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db_lock: add C++ helper class ScopeDatabaseLock
parent
7102ed80
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
11 deletions
+21
-11
SimpleDatabasePlugin.cxx
src/db/SimpleDatabasePlugin.cxx
+6
-11
db_lock.h
src/db_lock.h
+15
-0
No files found.
src/db/SimpleDatabasePlugin.cxx
View file @
0240e754
...
...
@@ -250,11 +250,8 @@ SimpleDatabase::LookupDirectory(const char *uri) const
assert
(
root
!=
NULL
);
assert
(
uri
!=
NULL
);
db_lock
();
struct
directory
*
directory
=
directory_lookup_directory
(
root
,
uri
);
db_unlock
();
return
directory
;
ScopeDatabaseLock
protect
;
return
directory_lookup_directory
(
root
,
uri
);
}
bool
...
...
@@ -281,12 +278,10 @@ SimpleDatabase::Visit(const DatabaseSelection &selection,
!
visit_directory
(
*
directory
,
error_r
))
return
false
;
db_lock
();
bool
ret
=
directory
->
Walk
(
selection
.
recursive
,
selection
.
filter
,
visit_directory
,
visit_song
,
visit_playlist
,
error_r
);
db_unlock
();
return
ret
;
ScopeDatabaseLock
protect
;
return
directory
->
Walk
(
selection
.
recursive
,
selection
.
filter
,
visit_directory
,
visit_song
,
visit_playlist
,
error_r
);
}
bool
...
...
src/db_lock.h
View file @
0240e754
...
...
@@ -81,4 +81,19 @@ db_unlock(void)
g_static_mutex_unlock
(
&
db_mutex
);
}
#ifdef __cplusplus
class
ScopeDatabaseLock
{
public
:
ScopeDatabaseLock
()
{
db_lock
();
}
~
ScopeDatabaseLock
()
{
db_unlock
();
}
};
#endif
#endif
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