How to interrupt boost::this_thread in c++

Mukul

In my application i have given sleep of 10 sec. I have given sleep using boost::this_thread::sleep function. Is there any possible way to interrupt boost::this_thread::sleep function.?

Some programmer dude

From the sleep() reference:

Throws: boost::thread_interrupted if the current thread of execution is interrupted.

Notes: sleep() is one of the predefined interruption points.

So what you need to do in your thread is to put the sleep() call in a try-catch, and catch boost::thread_interrupted. Then call interrupt() on the thread object to interrupt the sleep.


By the way, also from the sleep reference:

Warning

DEPRECATED since 3.0.0.

Use sleep_for() and sleep_until() instead.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to properly interrupt a thread in android

How interrupt/stop a thread in Java?

How can I immediately terminate a Thread? (Not interrupt)

Is it okay to use std::this_thread* functions from boost::threads?

How to interrupt other std::threads c++

RxJava: How to interrupt thread on unsubscribe?

std::thread class vs std::this_thread namespace in c++?

How to Control Thread Pool in Boost/C++ Implementation

How to interrupt blocking accept() call in C++?

C++ & boost::threads - How to prioritize thread based on work type?

Thread interrupt() does not interrupt thread

Threads: How to interrupt a thread from outside of that thread

boost::thread interrupt() throws an exception only the first time that an interruption point is executed?

How to interrupt a thread by button listener

Interrupt a thread

How exactly do I interrupt a thread?

C++11 std::this_thread - How to cancel sleep_until ()?

boost::thread interrupt asynchronously

how to stop a thread with thread interrupt method

How to know that a certain boost thread has been executed in boost C++?

Interrupt with C

How to interrupt a thread submitted to newSingleThreadExecutor in Java/Scala?

How to interrupt wait coroutine in a loop c#?

How to interrupt a thread which otherwise timeouts?

Can Boost::asio::post can interrupt the running thread?

How to interrupt Thread.sleep. Alternatives?

Interrupt all threads in the Boost Asio Thread Pool

How to correctly interrupt boost::asio::read on a boost::asio::serial_port under Linux?

How to interrupt another thread?