Skip to content

Commit 44297c6

Browse files
committed
Replaced logging handler mutex by shared pointers.
1 parent 47e8f86 commit 44297c6

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

libs/network/src/logging/logging.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
#endif
99

1010
#include <iostream>
11-
#include <boost/thread/shared_mutex.hpp>
12-
#include <boost/thread/shared_lock_guard.hpp>
11+
#include <memory>
1312
#include <network/logging/logging.hpp>
1413

1514
namespace network { namespace logging {
@@ -32,23 +31,22 @@ namespace handler
3231
namespace
3332
{
3433
// the log handler have to manage itself the thread safety on call
35-
log_record_handler current_log_record_handler = handler::std_log_handler;
36-
boost::upgrade_mutex mutex_log_handler; // we still need to not change the log handler concurrently
34+
static auto current_log_record_handler = std::make_shared<log_record_handler>( &handler::std_log_handler );
35+
3736
}
3837

3938

4039
void set_log_record_handler( log_record_handler handler )
4140
{
42-
boost::lock_guard<boost::upgrade_mutex> write_lock( mutex_log_handler );
43-
current_log_record_handler = handler;
41+
current_log_record_handler = std::make_shared<log_record_handler>( handler );
4442
}
4543

4644
void log( const log_record& log )
4745
{
48-
boost::shared_lock<boost::upgrade_mutex> read_lock( mutex_log_handler );
49-
if( current_log_record_handler )
46+
auto log_handler = current_log_record_handler;
47+
if( log_handler )
5048
{
51-
current_log_record_handler( log );
49+
(*log_handler)( log );
5250
}
5351
}
5452

0 commit comments

Comments
 (0)