mercredi 22 janvier 2020

How to check the status of detached thread in C++11?

I have tried searching many ways for the solution, but couldn't find proper one, so far.

I am using detached thread because I don't want my main thread to wait/block for the new child thread as it has many other important things to do.

I create a thread as follows:

std::thread rsync_t(&PreCompile::RunPreCompileThr, obj, arg1, arg2);
rsync_t.detach();

Now, Objective is to periodically check if this detached thread is active and running.

I tried future/promise and async way to do this, but it requires .get() which is something similar to join(), which I don't want.

Any suggestions to do this?

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire