made ThreadStaticActivator util (a static generic class that creates ThreadStatic instances)
This commit is contained in:
1 parent
247a41de23
commit
eef792d148
1 file changed
+9
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace bts.utils {
|
||||
static class ThreadStaticActivator<T> where T : class, new() {
|
||||
[ThreadStatic]
|
||||
static T _instance;
|
||||
public static T instance => _instance ?? (_instance = new T());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user