How to hardware wakeup and cancel thread_sleep_for();

I’m trying to wake up or stop/cancel a sleep function by a GPIO pin.
The interruptIn function is working, I can flip an LED during sleep to test, however the sleep remains active until it times out.

I could do this before with the earlier version of deepsleep.

I want the GPIO pin to cancel the sleep function.
Is there any way to do this?

Thank you

I have tried this in the interrupt call back ;


But results in lock up.

Could you use eventflags?

Possibly, but the documentation is so poor on Mbed I have no idea how to implement it.