adds documentation and adaptors for connection::close

This commit is contained in:
Peter Thorson
2013-02-01 07:41:04 -06:00
parent b999051959
commit d0cbb07d5c
2 changed files with 33 additions and 0 deletions

View File

@@ -251,6 +251,14 @@ public:
/* Connection pass through functions */
/*************************************/
/**
* These functions act as adaptors to their counterparts in connection. They
* can produce one additional type of error, the bad_connection error, that
* indicates that the conversion from connection_hdl to connection_ptr
* failed due to the connection not existing anymore. Each method has a
* default and an exception free varient.
*/
void interrupt(connection_hdl hdl, lib::error_code & ec);
void interrupt(connection_hdl hdl);
@@ -266,6 +274,11 @@ public:
void send(connection_hdl hdl, message_ptr msg, lib::error_code & ec);
void send(connection_hdl hdl, message_ptr msg);
void close(connection_hdl hdl, const close::status::value code,
const std::string & reason, lib::error_code & ec);
void close(connection_hdl hdl, const close::status::value code,
const std::string & reason);
protected:
// Import appropriate internal types from our policy classes
typedef typename concurrency_type::scoped_lock_type scoped_lock_type;

View File

@@ -160,6 +160,26 @@ void endpoint<connection,config>::send(connection_hdl hdl, message_ptr msg) {
if (ec) { throw ec; }
}
template <typename connection, typename config>
void endpoint<connection,config>::close(connection_hdl hdl,
const close::status::value code, const std::string & reason,
lib::error_code & ec)
{
connection_ptr con = get_con_from_hdl(hdl,ec);
if (ec) {return;}
ec = con->close(code,reason);
}
template <typename connection, typename config>
void endpoint<connection,config>::close(connection_hdl hdl,
const close::status::value code, const std::string & reason)
{
lib::error_code ec;
send(hdl,code,reason,ec);
if (ec) { throw ec; }
}
template <typename connection, typename config>
void endpoint<connection,config>::remove_connection(connection_ptr con) {
std::stringstream s;