diff --git a/src/ipc.cpp b/src/ipc.cpp index a0c6828..c9d02ef 100644 --- a/src/ipc.cpp +++ b/src/ipc.cpp @@ -84,6 +84,20 @@ struct cache_t { } }; +auto& recv_cache() { + /* + thread_local may have some bugs. + See: https://sourceforge.net/p/mingw-w64/bugs/727/ + https://sourceforge.net/p/mingw-w64/bugs/527/ + https://github.com/Alexpux/MINGW-packages/issues/2519 + https://github.com/ChaiScript/ChaiScript/issues/402 + https://developercommunity.visualstudio.com/content/problem/124121/thread-local-variables-fail-to-be-initialized-when.html + https://software.intel.com/en-us/forums/intel-c-compiler/topic/684827 + */ + static tls::pointer> rc; + return *rc.create(); +} + struct conn_info_head { using acc_t = std::atomic; @@ -191,20 +205,6 @@ constexpr static queue_t* queue_of(ipc::handle_t h) { return (info_of(h) == nullptr) ? nullptr : &(info_of(h)->que_); } -static auto& recv_cache() { - /* - thread_local may have some bugs. - See: https://sourceforge.net/p/mingw-w64/bugs/727/ - https://sourceforge.net/p/mingw-w64/bugs/527/ - https://github.com/Alexpux/MINGW-packages/issues/2519 - https://github.com/ChaiScript/ChaiScript/issues/402 - https://developercommunity.visualstudio.com/content/problem/124121/thread-local-variables-fail-to-be-initialized-when.html - https://software.intel.com/en-us/forums/intel-c-compiler/topic/684827 - */ - static tls::pointer> rc; - return *rc.create(); -} - /* API implementations */ static ipc::handle_t connect(char const * name, bool start) {