#include <thread>
#include <future>
#include <chrono>
#include <iostream>
#include <chrono>
using namespace std;

struct SharedStateWhichBlocks {
    ~SharedStateWhichBlocks()
    {
        thread t([]() {
            this_thread::sleep_for(std::chrono::seconds(5));
        });
        t.join();
        cout << "~SharedStateWhichBlocks" << endl;
    }
};

int main()
{

	auto start = std::chrono::high_resolution_clock::now();
    SharedStateWhichBlocks *state = new SharedStateWhichBlocks();
    {
        promise<SharedStateWhichBlocks> pr;
        future<SharedStateWhichBlocks> fut = pr.get_future();
        pr.set_value(*state);
        cout << "Will now block since ~SharedStateWhichBlocks will be called" << endl;
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto difference = std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
    std::cout << "Seconds for the block { ... } " << difference << endl;
}