lundi 31 octobre 2016

C++11 execute block in same thread but with timeout

Lets say we have block of code, we just cant modify it, but we want to break it, exit this piece of code when it runs too long (x miliseconds)

Pseudo code

Throw exception after (500ms) {
    auto result = Do some risky job, for example test string by regex with catastrophic backtracking risk.
}
catch ( Exception e ) {
    //... 
}

Every thing has to be still in the same thread.

Is it possible with c++11 or with some other standard?

Aucun commentaire:

Enregistrer un commentaire