summaryrefslogtreecommitdiff
path: root/src/SingletonHolder.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/SingletonHolder.h')
-rw-r--r--src/SingletonHolder.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/SingletonHolder.h b/src/SingletonHolder.h
index 7f8e2d69..dcfe9e33 100644
--- a/src/SingletonHolder.h
+++ b/src/SingletonHolder.h
@@ -35,30 +35,37 @@
#ifndef D_SINGLETON_HOLDER_H
#define D_SINGLETON_HOLDER_H
+#include "SharedHandle.h"
+
namespace aria2 {
template<typename T>
class SingletonHolder {
private:
- static T* instance_;
+ static SharedHandle<T> instance_;
SingletonHolder() {}
public:
~SingletonHolder() {}
- static T* instance()
+ static const SharedHandle<T>& instance()
{
return instance_;
}
- static void instance(T* instance)
+ static void instance(const SharedHandle<T>& instance)
{
instance_ = instance;
}
+
+ static void clear()
+ {
+ instance_.reset();
+ }
};
template<typename T>
-T* SingletonHolder<T>::instance_ = 0;
+SharedHandle<T> SingletonHolder<T>::instance_;
} // namespace aria2