I am developing a memory manager. The core is in C (Clang), and the API binding will be in the final language. Now it’s Delphi/FreePascal, then there will be headers for C/C++ companion compilers.
There is one important feature. At some moment, my function is called from an arbitrary thread created by someone in some language. At this moment, I need to register the callback thread to complete in order to properly clean it.
On Windows, I do this with fiber. I googled POSIX, they say there is pthread_cleanup_push.
But firstly, we do not have this macro in the headers. Secondly, apparently, he is obliged to work in tandem with pthread_cleanup_pop, i.e. is temporary:
https://godbolt.org/z/FB564hAll I found are two functions:
https://www.man7.org/linux/man-pages/man3/pthread_setcancelstate.3.htmlhttps://www.man7.org/linux/man-pages/man3/pthread_setcanceltype.3.htmlBut nowhere is it visible how you can specify a callback
Please tell me what to do