std::swap<div class="t-tr-text">(Std :: thread)<div class="t-tr-dropdown"><div><div><div class="t-tr-dropdown-arrow-border"></div><div class="t-tr-dropdown-arrow"></div><div class="t-tr-dropdown-h">Original:</div><div class="t-tr-dropdown-orig">(std::thread)</div><div class="t-tr-dropdown-notes">The text has been machine-translated via [http://translate.google.com Google Translate].<br/> You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.</div></div></div></div></div>

Da cppreference.com.
< cpp‎ | thread‎ | thread

 
 
Discussione libreria di supporto
Threads
Original:
Threads
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
thread(C++11)
this_thread spazio dei nomi
Original:
this_thread namespace
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
get_id(C++11)
yield(C++11)
sleep_for(C++11)
sleep_until(C++11)
Mutua esclusione
Original:
Mutual exclusion
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
mutex(C++11)
timed_mutex(C++11)
Blocco di gestione generico
Original:
Generic lock management
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
lock(C++11)
try_lock(C++11)
defer_lock
try_to_lock
adopt_lock
(C++11)
(C++11)
(C++11)
Condizioni variabili
Original:
Condition variables
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
condition_variable(C++11)
condition_variable_any(C++11)
notify_all_at_thread_exit(C++11)
cv_status(C++11)
Futures
Original:
Futures
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
promise(C++11)
future(C++11)
shared_future(C++11)
packaged_task(C++11)
async(C++11)
 
std::thread
Membri classi
Original:
Member classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
thread::id
Membri funzioni
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
thread::thread
thread::~thread
thread::operator=
Osservatori
Original:
Observers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
thread::joinable
thread::get_id
thread::native_handle
thread::hardware_concurrency
Operazioni
Original:
Operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
thread::join
thread::detach
thread::swap
Non membri funzioni
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::swap
 
void swap( thread &lhs, thread &rhs );
(dal C++11)
Sovraccarico l'algoritmo std::swap per std::thread. Scambi lo stato di lhs con quella di rhs. Chiama efficacemente lhs.swap(rhs).
Original:
Overloads the std::swap algorithm for std::thread. Exchanges the state of lhs with that of rhs. Effectively calls lhs.swap(rhs).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Indice

[modifica]Parametri

lhs, rhs -
discussioni i cui stati di scambiare
Original:
threads whose states to swap
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifica]Valore di ritorno

(Nessuno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifica]Eccezioni

noexcept specification:  
noexcept
  (dal C++11)

[modifica]Esempio

#include <iostream>#include <thread>#include <chrono>   void foo(){std::this_thread::sleep_for(std::chrono::seconds(1));}   void bar(){std::this_thread::sleep_for(std::chrono::seconds(1));}   int main(){std::thread t1(foo);std::thread t2(bar);   std::cout<<"thread 1 id: "<< t1.get_id()<<std::endl;std::cout<<"thread 2 id: "<< t2.get_id()<<std::endl;   std::swap(t1, t2);   std::cout<<"after std::swap(t1, t2):"<<std::endl;std::cout<<"thread 1 id: "<< t1.get_id()<<std::endl;std::cout<<"thread 2 id: "<< t2.get_id()<<std::endl;   t1.swap(t2);   std::cout<<"after t1.swap(t2):"<<std::endl;std::cout<<"thread 1 id: "<< t1.get_id()<<std::endl;std::cout<<"thread 2 id: "<< t2.get_id()<<std::endl;   t1.join(); t2.join();}

Output:

thread 1 id: 1892 thread 2 id: 2584 after std::swap(t1, t2): thread 1 id: 2584 thread 2 id: 1892 after t1.swap(t2): thread 1 id: 1892 thread 2 id: 2584

[modifica]Vedi anche

swap due oggetti filo
Original:
swaps two thread objects
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(metodo pubblico)[modifica]
close