Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions include/asio/basic_serial_port.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,37 @@ class basic_serial_port
return impl_.get_service().native_handle(impl_.get_implementation());
}

/// Release ownership of the underlying native serial port.
/*
* This function causes all outstanding asynchronous read and write
* operations to finish immediately, and the handlers for cancelled
* operations will be passed the asio::error::operation_aborted error.
* Ownership of the native serial port is then transferred to the caller.
*
* @throws asio::system_error Thrown on failure.
*/
native_handle_type release()
{
asio::error_code ec;
native_handle_type s = impl_.get_service().release(
impl_.get_implementation(), ec);
asio::detail::throw_error(ec, "release");
return s;
}

/// Release ownership of the underlying native serial port.
/*
* This function causes all outstanding asynchronous read and write
* operations to finish immediately, and the handlers for cancelled
* operations will be passed the asio::error::operation_aborted error.
* Ownership of the native serial port is then transferred to the caller.
*
* @param ec Set to indicate what error occurred, if any.
*/
native_handle_type release(asio::error_code& ec)
{
return impl_.get_service().release(impl_.get_implementation(), ec);
}
/// Cancel all asynchronous operations associated with the serial port.
/**
* This function causes all outstanding asynchronous read or write operations
Expand Down
7 changes: 7 additions & 0 deletions include/asio/detail/posix_serial_port_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ class posix_serial_port_service :
return descriptor_service_.native_handle(impl);
}

// Release ownership of the native serial port representation.
native_handle_type release(implementation_type& impl,
asio::error_code& ec)
{
return descriptor_service_.release(impl, ec);
}

// Cancel all operations associated with the serial port.
asio::error_code cancel(implementation_type& impl,
asio::error_code& ec)
Expand Down