diff options
author | Max Kellermann <max@musicpd.org> | 2018-01-02 12:26:53 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-01-02 12:26:53 +0100 |
commit | 5544375002c582e43246ac7e70aa5e6e3c8c3654 (patch) | |
tree | 70b1b56e50b9a4ea3dff7e21d1275207a39f5b14 /src/thread/SafeSingleton.hxx | |
parent | 1fd8d460646cd8a01e0cc1a8c310f395b472cae1 (diff) |
thread/SafeSingleton: pass parameters to constructor
Diffstat (limited to 'src/thread/SafeSingleton.hxx')
-rw-r--r-- | src/thread/SafeSingleton.hxx | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/thread/SafeSingleton.hxx b/src/thread/SafeSingleton.hxx index ce2f4bb81..386c1f376 100644 --- a/src/thread/SafeSingleton.hxx +++ b/src/thread/SafeSingleton.hxx @@ -37,11 +37,12 @@ class SafeSingleton { static T *instance; public: - SafeSingleton() { + template<typename... Args> + explicit SafeSingleton(Args&&... args) { const std::lock_guard<Mutex> lock(mutex); if (ref == 0) - instance = new T; + instance = new T(std::forward<Args>(args)...); /* increment after creating the instance; this way is exception-safe, because we must not increment the |