mardi 2 janvier 2018

How might I implement Java like "interrupted exception" behaviour in C++11

In java calls that wait on things, time, IO, semphores, etc will throw an "InterruptedException" when the thread waiting for the operation to complete is "interrupted".

Apparently the "SIGNAL"mechanism used by Pthreads in Linux, std::thread etc is a bit screwed up and difficult to manage.

I basically want to implement a way to abort mutex and semaphore waits, waiting joins etc from an "interrupt" ( kill or whatever ) call to a thread from another thread and catch via exception or return value that fact that this was done inside the thread being "interrupted", without effecting any other running thread.

Aucun commentaire:

Enregistrer un commentaire