Discussion about this post

User's avatar
Alireza Abbasi's avatar

In my received email, there is a wrong code that I past it in the below:

```

// We can use async, to defer execution of code until the end of the scope

{

FILE *file = fopen("/dev/null", "r");

auto deferred_close = std::async(std::launch::deferred, [file](){

fclose(file);

});

} // destructor for deferred_close runs and closes the file

```

But it doesn't work, and we should call get() or wait() method for execution of lambda function.

Expand full comment
Yacob Cohen-Arazi's avatar

do people really use it in production? for a test-scenario and quick and dirty async threading, it's nice but the lack of ctrl makes it less attractive for real production code. what do you think?

Expand full comment
2 more comments...

No posts