In threads, I know that terminate() is called when a thread variable leaves scope:
size_t fibrec(size_t n) { return n<2 ? 1 : fibrec(n-2)+fibrec(n-1); } int main() { std::thread th{ fibrec, 35 };
th destructor will call terminate() when it leaves scope.
But what about future s? Where is the thread they start? Did he separate? How did it end?
#include <iostream>
When execit() left, the futures f1 and f2 will be destroyed. But should their threads still work? Of course, the Fibrec destructor is called. But where are the flows going? The program does not crash, so I suppose it becomes integrated? Or maybe separated? Or are they discontinued or canceled? I believe this is not trivially done in C ++ 11?
source share