this_thread Namespace

Description

Namespace this_thread contains global functions related to threading.

Members

 namepace tbb {
        namespace this_thread {
            thread::id get_id();
            void yield();
            void sleep( const tick_count::interval_t );
        }
    }
     
The following table provides additional information on the members of this template class.
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

            using namespace tbb;
     
    void Foo() {
        // Sleep 30 seconds
        this_thread::sleep_for( tick_count::interval_t(30) );
    }