Ticket #3885: thread_ref.patch

File thread_ref.patch, 2.5 KB (added by viboes, 12 years ago)
  • thread_ref.qbk

     
    163163compare equal to each other, but not equal to any instances that refer to an actual thread of execution. The comparison operators on
    164164__thread_id__ yield a total order for every non-equal thread ID.
    165165
     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
     170This native handle can be used to change for example the scheduling.
     171
     172In 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
     181Any thread of execution created using the native interface is called a native thread in this documentation.
     182The first example of a native thread of execution is the main thread.
     183
     184The 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
     195Of course all the synchronization facilities provided by Boost.Thread are also available on native threads.
     196
     197The `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
     199As the single way to interrupt a thread is through a __thread__ instance, `interruption_request()` wiil returns false for the native threads.
     200
    166201[section:thread Class `thread`]
    167202
    168203    #include <boost/thread/thread.hpp>
     
    675710
    676711[endsect]
    677712
    678 [section:less_than_or_equal `operator>=`]
     713[section:less_than_or_equal `operator<=`]
    679714
    680715    bool operator<=(const id& y) const;
    681716