File tree Expand file tree Collapse file tree 2 files changed +14
-18
lines changed
include/bitcoin/network/channels Expand file tree Collapse file tree 2 files changed +14
-18
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,8 @@ class BCT_API channel
109109 void start_inactivity () NOEXCEPT;
110110 void handle_inactivity (const code& ec) NOEXCEPT;
111111
112+ void handle_monitor (const code& ec) NOEXCEPT;
113+
112114 // These are thread safe (const).
113115 const settings_t & settings_;
114116 const uint64_t identifier_;
Original file line number Diff line number Diff line change 2727namespace libbitcoin {
2828namespace network {
2929
30+ #define CLASS channel
31+
3032using namespace system ;
3133using namespace std ::placeholders;
3234
@@ -94,24 +96,16 @@ void channel::monitor(bool value) NOEXCEPT
9496{
9597 BC_ASSERT (stranded ());
9698
97- if (value)
98- {
99- // Invoke stop only if was *not* canceled (by cancel/stop).
100- wait ([&](const code& ec) NOEXCEPT
101- {
102- LOGA (" wait [" << authority () << " ] " << ec.message ());
103- if (ec) stop (ec);
104- });
105- }
106- else
107- {
108- // Invokes wait handler with operation_canceled (stop on fail).
109- cancel ([&](const code& ec) NOEXCEPT
110- {
111- LOGA (" cancel [" << authority () << " ] " << ec.message ());
112- if (ec) stop (ec);
113- });
114- }
99+ auto handler = std::bind (&channel::handle_monitor,
100+ shared_from_base<channel>(), _1);
101+
102+ value ? wait (std::move (handler)) : cancel (std::move (handler));
103+ }
104+
105+ void channel::handle_monitor (const code& ec) NOEXCEPT
106+ {
107+ BC_ASSERT (stranded ());
108+ if (ec) stop (ec);
115109}
116110
117111// Timers.
You can’t perform that action at this time.
0 commit comments