diff options
author | Max Kellermann <max@musicpd.org> | 2017-08-24 19:49:54 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-08-24 19:53:52 +0200 |
commit | 28a2d41b85fce58d02d1205620f8f4ad1d38a2b4 (patch) | |
tree | 689786dc90462cc04f1f4877e32b605eb33bf86f /src/db | |
parent | 7e76656a188436e20e0241f5a0e87696761936be (diff) |
db/DatabasePlugin: pass EventThread's EventLoop to create()
Allows database plugins to use the EventThread, e.g. for CURL
integration.
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/Configured.cxx | 8 | ||||
-rw-r--r-- | src/db/Configured.hxx | 2 | ||||
-rw-r--r-- | src/db/DatabaseGlue.cxx | 4 | ||||
-rw-r--r-- | src/db/DatabaseGlue.hxx | 1 | ||||
-rw-r--r-- | src/db/DatabasePlugin.hxx | 3 | ||||
-rw-r--r-- | src/db/plugins/ProxyDatabasePlugin.cxx | 7 | ||||
-rw-r--r-- | src/db/plugins/simple/SimpleDatabasePlugin.cxx | 2 | ||||
-rw-r--r-- | src/db/plugins/simple/SimpleDatabasePlugin.hxx | 4 | ||||
-rw-r--r-- | src/db/plugins/upnp/UpnpDatabasePlugin.cxx | 6 |
9 files changed, 25 insertions, 12 deletions
diff --git a/src/db/Configured.cxx b/src/db/Configured.cxx index 249a6e26e..5c0a1b00c 100644 --- a/src/db/Configured.cxx +++ b/src/db/Configured.cxx @@ -28,7 +28,7 @@ #include "util/RuntimeError.hxx" Database * -CreateConfiguredDatabase(EventLoop &main_event_loop, +CreateConfiguredDatabase(EventLoop &main_event_loop, EventLoop &io_event_loop, DatabaseListener &listener) { const auto *param = config_get_block(ConfigBlockOption::DATABASE); @@ -39,12 +39,12 @@ CreateConfiguredDatabase(EventLoop &main_event_loop, param->line, path->line); if (param != nullptr) - return DatabaseGlobalInit(main_event_loop, + return DatabaseGlobalInit(main_event_loop, io_event_loop, listener, *param); else if (path != nullptr) { ConfigBlock block(path->line); block.AddBlockParam("path", path->value.c_str(), path->line); - return DatabaseGlobalInit(main_event_loop, + return DatabaseGlobalInit(main_event_loop, io_event_loop, listener, block); } else { /* if there is no override, use the cache directory */ @@ -61,7 +61,7 @@ CreateConfiguredDatabase(EventLoop &main_event_loop, ConfigBlock block; block.AddBlockParam("path", db_file_utf8.c_str(), -1); - return DatabaseGlobalInit(main_event_loop, + return DatabaseGlobalInit(main_event_loop, io_event_loop, listener, block); } } diff --git a/src/db/Configured.hxx b/src/db/Configured.hxx index e2ba63ecc..287a40438 100644 --- a/src/db/Configured.hxx +++ b/src/db/Configured.hxx @@ -34,7 +34,7 @@ class Database; * Throws #std::runtime_error on error. */ Database * -CreateConfiguredDatabase(EventLoop &main_event_loop, +CreateConfiguredDatabase(EventLoop &main_event_loop, EventLoop &io_event_loop, DatabaseListener &listener); #endif diff --git a/src/db/DatabaseGlue.cxx b/src/db/DatabaseGlue.cxx index c5cd02977..e3863119f 100644 --- a/src/db/DatabaseGlue.cxx +++ b/src/db/DatabaseGlue.cxx @@ -27,6 +27,7 @@ Database * DatabaseGlobalInit(EventLoop &main_event_loop, + EventLoop &io_event_loop, DatabaseListener &listener, const ConfigBlock &block) { @@ -39,7 +40,8 @@ DatabaseGlobalInit(EventLoop &main_event_loop, plugin_name); try { - return plugin->create(main_event_loop, listener, block); + return plugin->create(main_event_loop, io_event_loop, + listener, block); } catch (...) { std::throw_with_nested(FormatRuntimeError("Failed to initialize database plugin '%s'", plugin_name)); diff --git a/src/db/DatabaseGlue.hxx b/src/db/DatabaseGlue.hxx index 43b8e2a8f..19ab87345 100644 --- a/src/db/DatabaseGlue.hxx +++ b/src/db/DatabaseGlue.hxx @@ -36,6 +36,7 @@ class Database; */ Database * DatabaseGlobalInit(EventLoop &main_event_loop, + EventLoop &io_event_loop, DatabaseListener &listener, const ConfigBlock &block); diff --git a/src/db/DatabasePlugin.hxx b/src/db/DatabasePlugin.hxx index db486a0cb..ee58c0a3e 100644 --- a/src/db/DatabasePlugin.hxx +++ b/src/db/DatabasePlugin.hxx @@ -49,8 +49,11 @@ struct DatabasePlugin { * * @param main_event_loop the #EventLoop running in the same * thread which invokes #Database methods + * @param io_event_loop the #EventLoop running on the + * #EventThread, i.e. the one used for background I/O */ Database *(*create)(EventLoop &main_event_loop, + EventLoop &io_event_loop, DatabaseListener &listener, const ConfigBlock &block); diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx index c39a96fa2..aa532cad2 100644 --- a/src/db/plugins/ProxyDatabasePlugin.cxx +++ b/src/db/plugins/ProxyDatabasePlugin.cxx @@ -107,7 +107,9 @@ public: ProxyDatabase(EventLoop &_loop, DatabaseListener &_listener, const ConfigBlock &block); - static Database *Create(EventLoop &loop, DatabaseListener &listener, + static Database *Create(EventLoop &main_event_loop, + EventLoop &io_event_loop, + DatabaseListener &listener, const ConfigBlock &block); void Open() override; @@ -345,7 +347,8 @@ ProxyDatabase::ProxyDatabase(EventLoop &_loop, DatabaseListener &_listener, } Database * -ProxyDatabase::Create(EventLoop &loop, DatabaseListener &listener, +ProxyDatabase::Create(EventLoop &loop, EventLoop &, + DatabaseListener &listener, const ConfigBlock &block) { return new ProxyDatabase(loop, listener, block); diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx index 2f72b4101..b2dbb4917 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx @@ -83,7 +83,7 @@ inline SimpleDatabase::SimpleDatabase(AllocatedPath &&_path, } Database * -SimpleDatabase::Create(gcc_unused EventLoop &loop, +SimpleDatabase::Create(EventLoop &, EventLoop &, gcc_unused DatabaseListener &listener, const ConfigBlock &block) { diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.hxx b/src/db/plugins/simple/SimpleDatabasePlugin.hxx index 2f771dba7..c18b580eb 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.hxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.hxx @@ -72,7 +72,9 @@ class SimpleDatabase : public Database { SimpleDatabase(AllocatedPath &&_path, bool _compress); public: - static Database *Create(EventLoop &loop, DatabaseListener &listener, + static Database *Create(EventLoop &main_event_loop, + EventLoop &io_event_loop, + DatabaseListener &listener, const ConfigBlock &block); gcc_pure diff --git a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx index 4a72b6d30..669bc37ef 100644 --- a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx +++ b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx @@ -75,7 +75,9 @@ class UpnpDatabase : public Database { public: UpnpDatabase():Database(upnp_db_plugin) {} - static Database *Create(EventLoop &loop, DatabaseListener &listener, + static Database *Create(EventLoop &main_event_loop, + EventLoop &io_event_loop, + DatabaseListener &listener, const ConfigBlock &block); void Open() override; @@ -138,7 +140,7 @@ private: }; Database * -UpnpDatabase::Create(gcc_unused EventLoop &loop, +UpnpDatabase::Create(EventLoop &, EventLoop &, gcc_unused DatabaseListener &listener, const ConfigBlock &) { |