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

https://developer.ridgerun.com/wiki/index.php/How_to_use_GPIO_signals

libsoc will do this out of the box for you.

https://github.com/jackmitch/libsoc

Cheers,