Simplify usage of Thread_Specific object
This commit is contained in:
parent
244b5b224b
commit
be2fec02d9
@ -67,44 +67,44 @@ namespace chaiscript
|
||||
class Thread_Storage
|
||||
{
|
||||
public:
|
||||
|
||||
explicit Thread_Storage(void *t_key)
|
||||
: m_key(t_key)
|
||||
{
|
||||
}
|
||||
Thread_Storage() = default;
|
||||
Thread_Storage(const Thread_Storage &) = delete;
|
||||
Thread_Storage(Thread_Storage &&) = delete;
|
||||
Thread_Storage &operator=(const Thread_Storage &) = delete;
|
||||
Thread_Storage &operator=(Thread_Storage &&) = delete;
|
||||
|
||||
~Thread_Storage()
|
||||
{
|
||||
t().erase(m_key);
|
||||
t().erase(this);
|
||||
}
|
||||
|
||||
inline const T *operator->() const
|
||||
{
|
||||
return &(t()[m_key]);
|
||||
return &(t()[this]);
|
||||
}
|
||||
|
||||
inline const T &operator*() const
|
||||
{
|
||||
return t()[m_key];
|
||||
return t()[this];
|
||||
}
|
||||
|
||||
inline T *operator->()
|
||||
{
|
||||
return &(t()[m_key]);
|
||||
return &(t()[this]);
|
||||
}
|
||||
|
||||
inline T &operator*()
|
||||
{
|
||||
return t()[m_key];
|
||||
return t()[this];
|
||||
}
|
||||
|
||||
|
||||
void *m_key;
|
||||
|
||||
private:
|
||||
static std::unordered_map<void*, T> &t()
|
||||
static std::unordered_map<const void*, T> &t()
|
||||
{
|
||||
thread_local static std::unordered_map<void *, T> my_t;
|
||||
thread_local std::unordered_map<const void *, T> my_t;
|
||||
return my_t;
|
||||
}
|
||||
};
|
||||
|
@ -452,7 +452,7 @@ namespace chaiscript
|
||||
};
|
||||
|
||||
explicit Dispatch_Engine(chaiscript::parser::ChaiScript_Parser_Base &parser)
|
||||
: m_stack_holder(this),
|
||||
: m_stack_holder(),
|
||||
m_parser(parser)
|
||||
{
|
||||
}
|
||||
|
@ -338,9 +338,7 @@ namespace chaiscript
|
||||
: m_mutex(),
|
||||
m_conversions(),
|
||||
m_convertableTypes(),
|
||||
m_num_types(0),
|
||||
m_thread_cache(this),
|
||||
m_conversion_saves(this)
|
||||
m_num_types(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user