Closed
Description
Instantiating an object of type Thread
will start the thread immediately.
If the thread can't be started then the system will enter in error
state.
It should be possible to use the c++ Thread
wrapper and recover from errors if the thread can't be started.
One solution could be to not start the thread at instantiation point but instead let the user start it explicitly by calling the function Thread::start
.
Another solution would be to embed a status in the Thread
object which allow to verify if the thread is started or not after its instantiation.
class Thread {
bool is_running();
operator bool() {
return is_running();
}
};
This change preserve backward compatibility and let the user write simple code like this:
Thread my_thread(do_something);
if (!my_thread) {
// thread not started
// recovery here
}
Metadata
Metadata
Assignees
Labels
No labels