| 166 | [heading Using native interfaces with Boost.Thread resources] |
| 167 | |
| 168 | __thread__ class has members `native_handle_type` and `native_handle` providing access to the underlying native handle. |
| 169 | |
| 170 | This native handle can be used to change for example the scheduling. |
| 171 | |
| 172 | In general, it is not safe to use this handle with operations that can conflict with the ones provided by Boost.Thread. An example of bad usage could be detaching a thread directly as it will not change the internals of the __thread__ instance, so for example the joinable function will continue to return true, while the native thread is no more joinable. |
| 173 | |
| 174 | thread t(fct); |
| 175 | thread::native_handle_type hnd=t.native_handle(); |
| 176 | pthread_detach(hnd); |
| 177 | assert(t.joinable()); |
| 178 | |
| 179 | [heading Using Boost.Thread in a native thread] |
| 180 | |
| 181 | Any thread of execution created using the native interface is called a native thread in this documentation. |
| 182 | The first example of a native thread of execution is the main thread. |
| 183 | |
| 184 | The user can access to some synchronization functions related to the native current thread using the `boost::this_thread` `yield`, `sleep`, functions. |
| 185 | |
| 186 | |
| 187 | int main() { |
| 188 | |
| 189 | // ... |
| 190 | boost::this_thread::sleep(); |
| 191 | // ... |
| 192 | |
| 193 | } |
| 194 | |
| 195 | Of course all the synchronization facilities provided by Boost.Thread are also available on native threads. |
| 196 | |
| 197 | The `boost::this_thread` interrupt related functions behave in a degraded mode when called from a thread created using the native interface, i.e. `boost::this_thread::interruption_enabled()` returns false. As consequence the use of `boost::this_thread::disable_interruption` and `boost::this_thread::restore_interruption` will do nothing and calls to `boost::this_thread::interrupt_point()` will be just ignored. |
| 198 | |
| 199 | As the single way to interrupt a thread is through a __thread__ instance, `interruption_request()` wiil returns false for the native threads. |
| 200 | |