Я попытался использовать pthread_cancel () < /code>, но это не помогло. IS: вызовите функцию и установите тайм -аут, если функция не вернулась в время дачи, затем выйдите из функции и продолжайте с функцией абонента.
Код: Выделить всё
#include
#include
#include
#include
#include
#include
using namespace std;
bool my_function(int &tid) {
// get thread id
tid = pthread_self();
printf("Thrd: TID=%d\n", tid);
while(1){} // hanged condition, this can be loop, or waiting for resource or mutex wait
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79586716/c-async-function-termination[/url]
Мобильная версия