db/DatabaseLock: add class ScopeDatabaseUnlock
This commit is contained in:
parent
e31f0b8b0c
commit
c11345c4d9
@ -107,4 +107,18 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Unlock the database while in the current scope.
|
||||
*/
|
||||
class ScopeDatabaseUnlock {
|
||||
public:
|
||||
ScopeDatabaseUnlock() {
|
||||
db_unlock();
|
||||
}
|
||||
|
||||
~ScopeDatabaseUnlock() {
|
||||
db_lock();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -232,14 +232,12 @@ Directory::Walk(bool recursive, const SongFilter *filter,
|
||||
/* TODO: eliminate this unlock/lock; it is necessary
|
||||
because the child's SimpleDatabasePlugin::Visit()
|
||||
call will lock it again */
|
||||
db_unlock();
|
||||
bool result = WalkMount(GetPath(), *mounted_database,
|
||||
recursive, filter,
|
||||
visit_directory, visit_song,
|
||||
visit_playlist,
|
||||
error);
|
||||
db_lock();
|
||||
return result;
|
||||
const ScopeDatabaseUnlock unlock;
|
||||
return WalkMount(GetPath(), *mounted_database,
|
||||
recursive, filter,
|
||||
visit_directory, visit_song,
|
||||
visit_playlist,
|
||||
error);
|
||||
}
|
||||
|
||||
if (visit_song) {
|
||||
|
@ -36,15 +36,14 @@ DatabaseEditor::DeleteSong(Directory &dir, Song *del)
|
||||
/* first, prevent traversers in main task from getting this */
|
||||
dir.RemoveSong(del);
|
||||
|
||||
db_unlock(); /* temporary unlock, because update_remove_song() blocks */
|
||||
/* temporary unlock, because update_remove_song() blocks */
|
||||
const ScopeDatabaseUnlock unlock;
|
||||
|
||||
/* now take it out of the playlist (in the main_task) */
|
||||
remove.Remove(del);
|
||||
|
||||
/* finally, all possible references gone, free it */
|
||||
del->Free();
|
||||
|
||||
db_lock();
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user