this_thread Namespace

Summary

Namespace this_thread contains global functions related to threading.

Members

 namespace std {
     namespace this_thread {
         thread::id get_id();
         void yield();
         void sleep( const tbb::tick_count::interval_t& );
     }
 }
                
The following table provides additional information on the functions in this namespace.
Member Description
thread::id get_id()

Returns: Id of the current thread.

void yield()

Offers to suspend current thread so that another thread may run.

void sleep_for( const tick_count::interval_t & i)

Current thread blocks for at least time interval i.

Example

    void Foo() {
        // Sleep 30 seconds
        std::this_thread::sleep_for( tbb::tick_count::interval_t(30) );
    }
                                         
For more complete information about compiler optimizations, see our Optimization Notice.