I am porting C++ library from Windows to Linux. This is multi-threaded library. In Windows version there are __try/__finally
block used for freeing resources and other activity after thread end. GCC doesn't support __try/__finally
and C++ standard doesn't support it, because C++ have RAII
. But how can i apply it to thread function?(destructor for function??).
I need to do some work then thread ended no matter which way (exception or normal return).
Is there any way to do this without writing catch(...)
with "destructor" code and adding "destructor" code to all returns?