| 71 | } |
| 72 | |
| 73 | T** get() const { |
| 74 | if (auto d = pthread_getspecific(m_key)) { |
| 75 | return static_cast<ThreadData*>(d)->data; |
| 76 | } |
| 77 | ThreadData* t_data = new ThreadData(); |
| 78 | #if defined(__ANDROID__) || defined(__OHOS__) |
| 79 | get_thread_local_force_free_instance().push((void*)t_data); |
| 80 | #endif |
| 81 | |
| 82 | t_data->data = m_constructor(); |
| 83 | t_data->self = this; |
| 84 | pthread_setspecific(m_key, t_data); |
| 85 | return t_data->data; |
| 86 | } |
| 87 | |
| 88 | static void exit(void* d) { |
| 89 | ThreadData* td = static_cast<ThreadData*>(d); |