fix(util/thread_script_state): add a better workaround for clang++ bug
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
89a7898054
commit
af0b02f521
1 changed files with 8 additions and 6 deletions
|
@ -92,16 +92,18 @@ struct script_state_ref {
|
|||
~script_state_ref() { recycle_state(m_state); }
|
||||
};
|
||||
|
||||
// We should use std::unique_ptr, but clang++ 3.3.1 crashes when we use it.
|
||||
std::shared_ptr<script_state_ref> LEAN_THREAD_LOCAL g_thread_state;
|
||||
static std::unique_ptr<script_state_ref> & get_script_state_ref() {
|
||||
static std::unique_ptr<script_state_ref> LEAN_THREAD_LOCAL g_thread_state;
|
||||
if (!g_thread_state)
|
||||
g_thread_state.reset(new script_state_ref());
|
||||
return g_thread_state;
|
||||
}
|
||||
|
||||
script_state get_thread_script_state() {
|
||||
if (!g_thread_state)
|
||||
g_thread_state = std::make_shared<script_state_ref>();
|
||||
return g_thread_state->m_state;
|
||||
return get_script_state_ref()->m_state;
|
||||
}
|
||||
|
||||
void release_thread_script_state() {
|
||||
g_thread_state = nullptr;
|
||||
get_script_state_ref().reset(nullptr);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue