Forum > Unix
pthread_cleanup_push analog
(1/1)
DevilDevil:
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/FB564h
All I found are two functions:
https://www.man7.org/linux/man-pages/man3/pthread_setcancelstate.3.html
https://www.man7.org/linux/man-pages/man3/pthread_setcanceltype.3.html
But nowhere is it visible how you can specify a callback
Please tell me what to do
marcov:
Look at the headers of the multiple supported *nixes.
Manpages are often simplified.
DevilDevil:
--- Quote from: marcov on June 02, 2020, 10:35:50 pm ---Look at the headers of the multiple supported *nixes.
--- End quote ---
It is too difficult for me: https://code.woboq.org/gcc/include/pthread.h.html#574
DevilDevil:
I heard that FPC can finalize threadvar.
I need similar functionality. But in the source I did not find the corresponding code. Can we attract FPC developers?
PascalDragon:
All threadvar related functionality for pthreads is located inside rtl/unix/cthreads.pp.
Navigation
[0] Message Index