Commit ddd5f55 1 parent a2c4bb3 commit ddd5f55 Copy full SHA for ddd5f55
File tree 2 files changed +9
-8
lines changed
2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change 28
28
namespace pipy {
29
29
30
30
Net* Net::s_main = nullptr ;
31
- thread_local Net Net::s_current;
31
+
32
+ auto Net::current () -> Net& {
33
+ static thread_local Net s_current;
34
+ return s_current;
35
+ }
32
36
33
37
void Net::init () {
34
- s_main = &s_current ;
38
+ s_main = ¤t () ;
35
39
36
40
#ifdef _WIN32
37
41
asio::detail::win_thread::set_terminate_threads (true );
Original file line number Diff line number Diff line change @@ -48,15 +48,13 @@ class Net {
48
48
return *s_main;
49
49
}
50
50
51
- static auto current () -> Net& {
52
- return s_current;
53
- }
51
+ static auto current () -> Net&;
54
52
55
53
static auto context () -> asio::io_context& {
56
- return s_current .m_io_context ;
54
+ return current () .m_io_context ;
57
55
}
58
56
59
- static bool is_main () { return &s_current == s_main; }
57
+ static bool is_main () { return ¤t () == s_main; }
60
58
61
59
auto io_context () -> asio::io_context& { return m_io_context; }
62
60
bool is_running () const { return m_is_running; }
@@ -72,7 +70,6 @@ class Net {
72
70
asio::io_context m_io_context;
73
71
bool m_is_running;
74
72
static Net* s_main;
75
- static thread_local Net s_current;
76
73
};
77
74
78
75
//
You can’t perform that action at this time.
0 commit comments