In my project I have function as defined below:
void start(std::chrono::milliseconds delay) override
{
mDelay = delay;
if(mThread == nullptr)
{
mThread = std::make_unique<Thread>([&]()
{
sleep(std::chrono::milliseconds(mDelay));
});
}
}
When I call the method for first time the thread is created and goes to sleep for mDelay period. But I need to change the mDelay time again but for a lesser time period that earlier one supplied.
But when I call it again I am unable to cancel the previous sleep and start a new one with defined mDelay?
How can I achieve the same?
Aucun commentaire:
Enregistrer un commentaire