#include #include thread Cleaner {}; static inline void ^?{} ( Cleaner &mutex this ) {} static inline void cleanup( Cleaner &mutex this ) {} void main( Cleaner & this ) { waitfor( cleanup : this ) { sout | "Cleaning"; } waitfor( ^?{} : this ) { sout | "Done"; } } int main() { // Creates a thread that will call the destructor // when the thread exits Cleaner c; cleanup( c ); }