How to hardware wakeup and cancel thread_sleep_for();

Hi,
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 ;

thread_sleep_for(0);

But results in lock up.

Could you use eventflags? https://os.mbed.com/docs/mbed-os/v6.2/apis/eventflags.html

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