title: Unblock synchronous read on boost::asio::serial_port
body: <p>I have a <code>boost::thread</code> which performs synchronous reads on a <code>boost::asio::serial_port</code>. When I destroy an instance of the class which contains both, I want the thread to end gracefully even if its blocked in a read call. How can I do this?</p>
  
  <p>Looking at the <a href="http://www.boost.org/doc/libs/1_48_0/doc/html/boost_asio/reference/serial_port.html" rel="noreferrer">docs</a>, I tried <code>cancel</code>, but it works only for asynchronous reads/writes. Then I tried <code>close</code>, but I got an exception and it wasn't the kind you can recover from. Perhaps using <code>send_break</code> or <code>native_handle</code>? (this is Windows and portability's not critical)</p>
  
  <p><strong>Update</strong>: I also tried to <code>stop</code> the <code>io_service</code> I passed to the serial port object's constructor, but the <code>read</code> wasn't unblocked.</p>
  
  <p><strong>Edit</strong>: The exception is actually "catchable", but I'd hate to put a try/catch block inside a destructor, and refactoring the code to do the shutdown process outside the destructor would trigger lots of changes in upper layers. So I'd only go for this solution if some Boost authority says there is no other way.</p>