Skip to content
Merged
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
11 changes: 6 additions & 5 deletions include/bitcoin/network/log/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ class BCT_API logger final

/// If stopped, handler is invoked with error::subscriber_stopped/defaults
/// and dropped. Otherwise it is held until stop/drop. False if failed.
void subscribe_messages(message_notifier&& handler) NOEXCEPT;
void subscribe_events(event_notifier&& handler) NOEXCEPT;
void subscribe_messages(message_notifier&& handler) const NOEXCEPT;
void subscribe_events(event_notifier&& handler) const NOEXCEPT;

/// Stop subscribers/pool with final message/empty posted to subscribers.
void stop(const code& ec, const std::string& message, uint8_t level) NOEXCEPT;
Expand All @@ -127,11 +127,12 @@ class BCT_API logger final
std::string&& message) const NOEXCEPT;

private:
void do_subscribe_messages(const message_notifier& handler) NOEXCEPT;
void do_subscribe_messages(
const message_notifier& handler) const NOEXCEPT;
void do_notify_message(const code& ec, uint8_t level, time_t zulu,
const std::string& message) const NOEXCEPT;

void do_subscribe_events(const event_notifier& handler) NOEXCEPT;
void do_subscribe_events(const event_notifier& handler) const NOEXCEPT;
void do_notify_event(uint8_t event, uint64_t value,
const time& point) const NOEXCEPT;

Expand All @@ -144,7 +145,7 @@ class BCT_API logger final
// These are thread safe.
std::atomic_bool stopped_{ false };
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
asio::strand strand_{ pool_.service().get_executor() };
mutable asio::strand strand_{ pool_.service().get_executor() };
BC_POP_WARNING()

// These are protected by strand.
Expand Down
9 changes: 5 additions & 4 deletions src/log/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void logger::do_notify_message(const code& ec, uint8_t level, time_t zulu,
message_subscriber_.notify(ec, level, zulu, message);
}

void logger::subscribe_messages(message_notifier&& handler) NOEXCEPT
void logger::subscribe_messages(message_notifier&& handler) const NOEXCEPT
{
if (stopped())
{
Expand All @@ -133,7 +133,8 @@ void logger::subscribe_messages(message_notifier&& handler) NOEXCEPT
}

// private
void logger::do_subscribe_messages(const message_notifier& handler) NOEXCEPT
void logger::do_subscribe_messages(
const message_notifier& handler) const NOEXCEPT
{
BC_ASSERT(stranded());
message_subscriber_.subscribe(move_copy(handler));
Expand All @@ -157,7 +158,7 @@ void logger::do_notify_event(uint8_t event_, uint64_t value,
event_subscriber_.notify(error::success, event_, value, point);
}

void logger::subscribe_events(event_notifier&& handler) NOEXCEPT
void logger::subscribe_events(event_notifier&& handler) const NOEXCEPT
{
if (stopped())
{
Expand All @@ -171,7 +172,7 @@ void logger::subscribe_events(event_notifier&& handler) NOEXCEPT
}

// private
void logger::do_subscribe_events(const event_notifier& handler) NOEXCEPT
void logger::do_subscribe_events(const event_notifier& handler) const NOEXCEPT
{
BC_ASSERT(stranded());
event_subscriber_.subscribe(move_copy(handler));
Expand Down
Loading