mirror of https://github.com/kiwix/libkiwix.git
Introduced Library::getBookByIdThreadSafe()
This commit is contained in:
parent
02b9e32d18
commit
473d2d2a69
|
@ -220,6 +220,8 @@ class Library : private LibraryBase
|
||||||
// XXX: This is a non-thread-safe operation
|
// XXX: This is a non-thread-safe operation
|
||||||
const Book& getBookByPath(const std::string& path) const;
|
const Book& getBookByPath(const std::string& path) const;
|
||||||
|
|
||||||
|
Book getBookByIdThreadSafe(const std::string& id) const;
|
||||||
|
|
||||||
std::shared_ptr<Reader> getReaderById(const std::string& id);
|
std::shared_ptr<Reader> getReaderById(const std::string& id);
|
||||||
std::shared_ptr<zim::Archive> getArchiveById(const std::string& id);
|
std::shared_ptr<zim::Archive> getArchiveById(const std::string& id);
|
||||||
|
|
||||||
|
|
|
@ -156,6 +156,12 @@ const Book& Library::getBookById(const std::string& id) const
|
||||||
return m_books.at(id);
|
return m_books.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Book Library::getBookByIdThreadSafe(const std::string& id) const
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
return getBookById(id);
|
||||||
|
}
|
||||||
|
|
||||||
const Book& Library::getBookByPath(const std::string& path) const
|
const Book& Library::getBookByPath(const std::string& path) const
|
||||||
{
|
{
|
||||||
// XXX: Doesn't make sense to lock this operation since it cannot
|
// XXX: Doesn't make sense to lock this operation since it cannot
|
||||||
|
|
Loading…
Reference in New Issue