4 Comments

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

Yes, it was a mistake that managed to survive into the example. The updated code is correct.

Expand full comment

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

Not really, it would be much better if the first argument was a customization point.

I think we are supposed to get something like std::async with executors.

Expand full comment