Forum > Unix

pthread_cleanup_push analog


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:

All I found are two functions:

But nowhere is it visible how you can specify a callback
Please tell me what to do

Look at the headers of the multiple supported *nixes.

Manpages are often simplified.


--- 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:

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?

All threadvar related functionality for pthreads is located inside rtl/unix/cthreads.pp.


[0] Message Index

Go to full version