I'm prototyping an extension in which I need to execute a C function repeatedly on a timer as part of a sql execution hook, and end it when I choose.
I have a working implementation that at a high level does the following
/* register and enable the timeout to call my_handler_proc every second */
tId = RegisterTimeout(USER_TIMEOUT, my_handler_proc);
enable_timeout_after((int)tId, 1000);
...
/* stop the timeout */
disable_timeout((int)tId, 0);
Note: I'm also working on the code to ensure I don't try to allocate beyond MAX_TIMEOUTS but I haven't shown that here for brevity.
My question really is: should I be doing this? Is it safe? I can't find this documented nor any other examples of code that uses this which is a red flag for me.
Thanks in advance,
Steve.