aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/includes/hicn/transport/utils/singleton.h
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport/includes/hicn/transport/utils/singleton.h')
-rw-r--r--libtransport/includes/hicn/transport/utils/singleton.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/libtransport/includes/hicn/transport/utils/singleton.h b/libtransport/includes/hicn/transport/utils/singleton.h
index 4b7b19c0a..cdd8b03bf 100644
--- a/libtransport/includes/hicn/transport/utils/singleton.h
+++ b/libtransport/includes/hicn/transport/utils/singleton.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -32,4 +32,17 @@ class Singleton : NonCopyable {
~Singleton() {}
};
+template <typename T>
+class ThreadLocalSingleton : NonCopyable {
+ public:
+ static T& getInstance() {
+ static thread_local T instance;
+ return instance;
+ }
+
+ protected:
+ ThreadLocalSingleton() {}
+ ~ThreadLocalSingleton() {}
+};
+
} // namespace utils \ No newline at end of file