[ Web Proxy ]
URL:
Viewing: https://fr.cppreference.com/cpp/thread/packaged_task [Back]  [Original]

std::packaged_task cppreference.com
cppreference.com
Espaces de noms
Variantes

std::packaged_task

De cppreference.com

<metanoindex/>

 
 
Bibliothque de support fil
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 espace de noms
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)
L'exclusion mutuelle
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)
Gestion du verrouillage gnrique
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_guard (C++11)
unique_lock (C++11)
defer_lock_t
try_to_lock_t
adopt_lock_t
(C++11)
(C++11)
(C++11)
lock (C++11)
try_lock (C++11)
defer_lock
try_to_lock
adopt_lock
(C++11)
(C++11)
(C++11)
Les variables de condition
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)
launch (C++11)
future_status (C++11)
future_error (C++11)
future_category (C++11)
future_errc (C++11)
 
std::packaged_task
Les fonctions membres
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.
packaged_task::packaged_task
packaged_task::~packaged_task
packaged_task::operator=
packaged_task::valid
packaged_task::swap
Obtenir le rsultat
Original:
Getting the result
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
packaged_task::get_future
Excution
Original:
Execution
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
packaged_task::operator()
packaged_task::make_ready_at_thread_exit
packaged_task::reset
 
<tbody> </tbody>
Dclar dans l'en-tte <future>
template< class > class packaged_task; //not defined
(1) (depuis C++11)
template< class R, class Args... > class packaged_task<R(Args...)>;
(2) (depuis C++11)
Le modle std::packaged_task classe encapsule une cible appelable (fonction, expression lambda, l'expression de liaison, ou un autre objet de fonction) de sorte qu'il peut tre appele de faon asynchrone, et sa valeur de retour ou exception leve est stocke dans l'tat partag, qui peut tre consulte par le biais std::future objets .
Original:
The class template std::packaged_task wraps any callable target (function, lambda expression, bind expression, or another function object) so that it can be invoked asynchronously, and its return value or exception thrown is stored in the shared state, which can be accessed through std::future objects.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tout comme std::function, std::packaged_task est un polymorphe, allocateur-aware conteneur: la cible appelable stockes peuvent tre alloues sur le tas ou avec un allocateur fournie .
Original:
Just like std::function, std::packaged_task is a polymorphic, allocator-aware container: the stored callable target may be allocated on heap or with a provided allocator.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Fonctions membres

construit l'objet de la tche
Original:
constructs the task object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
Dtruit l'objet de la tche
Original:
destructs the task object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
dplace l'objet tche
Original:
moves the task object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
vrifie si l'objet de la tche a une fonction valide
Original:
checks if the task object has a valid function
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
swaps de deux objets de tche
Original:
swaps two task objects
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
Obtenir le rsultat
Original:
Getting the result
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
renvoie une std::future associ au rsultat promis
Original:
returns a std::future associated with the promised result
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
Excution
Original:
Execution
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
excute la fonction
Original:
executes the function
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
excute la fonction de faire en sorte que le rsultat est prt une fois que le thread courant
Original:
executes the function ensuring that the result is ready only once the current thread exits
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
rinitialise l'tat des rsultats enregistrs l'abandon des excutions prcdentes
Original:
resets the state abandoning any stored results of previous executions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]

Fonctions annexes

l'algorithme spcialis std::swap
Original:
specializes the std::swap algorithm
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction gnrique) [edit]

Classes d'aide

se spcialise le trait de type std::uses_allocator
Original:
specializes the std::uses_allocator type trait
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(classe gnrique spcialise) [edit]

Exemple

#include <iostream>
#include <future>
#include <thread>

int main()
{
    std::packaged_task<int()> task([](){return 7;}); // wrap the function
    std::future<int> result = task.get_future();  // get a future
    std::thread(std::move(task)).detach(); // launch on a thread
    std::cout << "Waiting...";
    result.wait();
    std::cout << "Done!\nResult is " << result.get() << '\n';
}

Rsultat :

Waiting...Done!
Result is 7

Voir aussi

(C++11)
attend une valeur qui est dfinie de manire asynchrone
Original:
waits for a value that is set asynchronously
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(classe gnrique) [edit]

Web Proxy Viewer  |  New URL  |  Original Page