c++11 - Why std::thread doesn't have try_join_for() and interrupt() methods -


Can anyone explain to me why std :: thread to boost :: Thread of the following:

  1. There are no try_join_for / try_join_until methods
  2. any Interrupt method

    Here are some explanations:

    There is no way to request a thread ending (i.e. request that Get out of it as soon as possible and with as much grace as possible) or close a thread Forcing it to kill (i.e. kill it). We have omitted the options of

    1. , designing our own cooperative "interception mechanism". (With a piece of shared data that the caller thread can set to check a thread, and exit it quickly and quickly from being set),
    2. Go to a local Used to be ????
    3. Kill the process ( std :: quick_exit () ), using the thread :: country_handle () to obtain the perception of the operating system of thread:
    4. Kill the program ( std :: terminate () ). All this committee could agree on this. In particular, Posx's representatives strongly criticized against any kind of 'cancellation'. However, many C ++ models of resources rely on destructors. There is no perfect solution for every system and every possible application.

      But perhaps there is more complete explanation? Such methods ( try_join and interruptions ) are sometimes very useful.

      Well, you answered your question to yourself. The important difference between boost and C + 11 standard is that, C + 11 is a standard, so basically everyone had to agree to the methods and functions related to the thread. But as you already told us, "such methods (try_join and interrupt) sometimes are very useful"

      So whether it's standard for each compiler Would it be appropriate to apply? Maybe, but if you really need it then you can only use those promoting counterparts as long as it is not included in the standard. @ Howard-Hannad suggested: There were voices on the committee, the cooperative thread can be implemented portable in C ++ not able at promotion time: Thread Was not in the middle. Therefore, Anthony Williams implemented conscience to promote large scale, because at present it was proposed as a proof of the concept that it can be implemented Was mainly ignored by the committee, mainly because the subject had already been spent a long time, due to this one issue, the entire standard was submerged Kept the risk of it.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -