PostgreSQL makes use of background workers to allow processes working in a concurrent fashion and they have an API for backend/extension developers to control them. So far, I have managed to successfully work with this feature in a demo extension, successfully spawning a number of workers.
I am in a situation where one of my workers has to wait for another to finish. What I am doing so far is an infinite loop on an idle worker until the worker being waited for is finished, which can be quite inefficient. So I was wondering how would I go about making the idle process sleep until some signal is sent? What would I be looking for? Is there an extension which does something similar so that I could use for guidance?