3

I am working on a C++ project that uses boost 1.61, I am replacing boost with std calls, is there an alternative to boost::this_thread::interruption_point() ?

SPlatten
  • 5,334
  • 11
  • 57
  • 128

1 Answers1

5

std::thread is not interruptable. You can read more about this here. However there is std::jthread in C++-20, that you can try to use. Unfortunately, according to compiler-support list on cpp-reference, only libstdc++ 10+ supports std::jthread.

ForEveR
  • 55,233
  • 2
  • 119
  • 133
  • Unfortunately this isn't an option I can use as I'm limited to version of C++ available. The development environment is VS2013. – SPlatten Apr 29 '20 at 11:23
  • @SPlatten, then you can either not rewrite work with thread on std, or you can attempt to use native handle and interrupt it, if there is no need in cross-platforming. – ForEveR Apr 29 '20 at 11:27
  • I just opened the thread C++11 header, it does not contain jthread. – SPlatten Apr 29 '20 at 11:32
  • I'll give you the tick, because I don't think there is a correct answer to my particular problem but you have been very helpful. – SPlatten Apr 29 '20 at 11:42
  • A more correct answer is to use the approach to implement it yourself like in CCiA https://www.manning.com/books/c-plus-plus-concurrency-in-action-second-edition – sehe Apr 29 '20 at 16:27