Opened 10 years ago
Closed 10 years ago
#7238 closed Bugs (fixed)
this_thread::sleep_for() does not respond to interrupt()
Reported by: | CSB | Owned by: | viboes |
---|---|---|---|
Milestone: | Boost 1.52.0 | Component: | thread |
Version: | Boost 1.50.0 | Severity: | Problem |
Keywords: | thread sleep_for interrupt | Cc: |
Description
Calling the interrupt() member of a thread has no effect when the thread calls this_thread::sleep_for(). The trivial program used to test this did exhibit the correct behaviour for this_thread::sleep_until() and this_thread::sleep().
Test run on CentOS 6.3
Attachments (1)
Change History (7)
comment:1 by , 10 years ago
follow-up: 3 comment:2 by , 10 years ago
Severity: | Showstopper → Problem |
---|
Thanks for catching this.
I don't think this is a Showstopper as you can add a call to this_thread::interruption_point() together with the call to sleep_for, isn't it?
comment:3 by , 10 years ago
Replying to viboes:
Thanks for catching this.
I don't think this is a Showstopper as you can add a call to this_thread::interruption_point() together with the call to sleep_for, isn't it?
Forget the last comment.
comment:4 by , 10 years ago
Milestone: | To Be Determined → Boost 1.52.0 |
---|
Committed in trunk revision 80076.
comment:5 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:6 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Merged to release [80450].
I am also observing the issue on Ubuntu 12.04. See the test reproducer below.
The problem seems to be due to the following. On platforms where BOOST_HAS_NANOSLEEP is defined, a nanosleep-based implementation is used for sleep_for (see thread/src/pthread/thread.cpp), which presumably does not allow the interruption mechanisms to work. Commenting out the BOOST_HAS_NANOSLEEP section in the above file and allowing the condition_variable based implementation to be used causes the above example to run as expected.