Asynchronous GPIO Input example

I have been trying to find a good example of GPIO Input where a thread blocks until input changes.
Are these any such examples ? Is it even possible ? I have looked at Derek Molloy’s code it is
polling file in a tight loop.

Certainly there has to be another way of doing the GPIO input more efficiently?

Ok I am answering my own question, I found the following page that describes how to do this. I haven’t tested yet though

libsoc will do this out of the box for you.