| 149 | } |
| 150 | |
| 151 | bool thread::wait(void** out /* = NULL */) |
| 152 | { |
| 153 | if (detachable_) { |
| 154 | logger_error("detachable thread can't be wait!"); |
| 155 | return false; |
| 156 | } |
| 157 | |
| 158 | wait_for_running(); |
| 159 | |
| 160 | if (thread_id_ == 0) { |
| 161 | logger_error("thread not running!"); |
| 162 | return false; |
| 163 | } |
| 164 | |
| 165 | void* ptr; |
| 166 | |
| 167 | #ifdef ACL_WINDOWS |
| 168 | int ret = acl_pthread_join(*((acl_pthread_t*) thread_), &ptr); |
| 169 | #else |
| 170 | int ret = acl_pthread_join(thread_, &ptr); |
| 171 | #endif |
| 172 | |
| 173 | if (ret != 0) { |
| 174 | acl_set_error(ret); |
| 175 | logger_error("pthread_join error: %s", last_serror()); |
| 176 | return false; |
| 177 | } |
| 178 | |
| 179 | // �Ƚ�ͨ���� thread_run �нػ�IJ����� pthread_join ��õIJ����Ƿ���ͬ |
| 180 | if (ptr != return_arg_) { |
| 181 | logger_warn("pthread_josin's arg invalid?"); |
| 182 | } |
| 183 | |
| 184 | if (out) { |
| 185 | *out = ptr; |
| 186 | } |
| 187 | return true; |
| 188 | } |
| 189 | |
| 190 | unsigned long thread::thread_id() const |
| 191 | { |