...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::signals2::scoped_connection — Limits a signal-slot connection lifetime to a particular scope.
// In header: <boost/signals2/connection.hpp> class scoped_connection : public connection { public: // construct/copy/destruct scoped_connection(); scoped_connection(const connection&); ~scoped_connection(); // public methods scoped_connection & operator=(const connection &); connection release(); private: // construct/copy/destruct scoped_connection(const scoped_connection&); scoped_connection& operator=(const scoped_connection&); };
A connection which automatically disconnects on destruction.
The methods of the scoped_connection
class (including those
inherited from its base connection
class) are thread-safe with the exception
of connection::swap, release, and
the assignment operator A scoped_connection
object
should not be accessed concurrently when any of these operations is in progress.
However, it is always safe to access a different connection
object
in another thread, even if it references the same underlying signal-slot connection.
scoped_connection
public construct/copy/destructscoped_connection();
Default constructs an empty scoped_connection.
Postconditions: |
|
Throws: |
Will not throw. |
scoped_connection(const connection& other);
Effects: |
|
Postconditions: |
|
Throws: |
Will not throw. |
~scoped_connection();
Effects: |
If
|
scoped_connection
public methodsscoped_connection & operator=(const connection & rhs);
Effects: |
|
Postconditions: |
|
connection release();
Effects: |
Releases the connection so it will not be disconnected by the |
Postconditions: |
|
Returns: |
A connection object referencing the connection which was
released by the |
scoped_connection
private construct/copy/destructscoped_connection(const scoped_connection& other);
The scoped_connection class is not copyable. It may only be constructed from a connection
object.
scoped_connection& operator=(const scoped_connection& rhs);
The scoped_connection class is not copyable. It may only be assigned from a connection
object.