@ -218,19 +218,17 @@ private:
Impl ( const std : : filesystem : : path & file_backend_filename , const Filter & filter_ )
Impl ( const std : : filesystem : : path & file_backend_filename , const Filter & filter_ )
: filter { filter_ } , file_backend { file_backend_filename } { }
: filter { filter_ } , file_backend { file_backend_filename } { }
~ Impl ( ) {
~ Impl ( ) = default ;
StopBackendThread ( ) ;
}
void StartBackendThread ( ) {
void StartBackendThread ( ) {
backend_thread = std : : thread ( [ this ] {
backend_thread = std : : jthread ( [ this ] ( std : : stop_token stop_token ) {
Common : : SetCurrentThreadName ( " yuzu:Log " ) ;
Common : : SetCurrentThreadName ( " yuzu:Log " ) ;
Entry entry ;
Entry entry ;
const auto write_logs = [ this , & entry ] ( ) {
const auto write_logs = [ this , & entry ] ( ) {
ForEachBackend ( [ & entry ] ( Backend & backend ) { backend . Write ( entry ) ; } ) ;
ForEachBackend ( [ & entry ] ( Backend & backend ) { backend . Write ( entry ) ; } ) ;
} ;
} ;
while ( ! stop . stop_requested ( ) ) {
while ( ! stop _token . stop_requested ( ) ) {
entry = message_queue . PopWait ( stop . get _token( ) ) ;
entry = message_queue . PopWait ( stop _token) ;
if ( entry . filename ! = nullptr ) {
if ( entry . filename ! = nullptr ) {
write_logs ( ) ;
write_logs ( ) ;
}
}
@ -244,11 +242,6 @@ private:
} ) ;
} ) ;
}
}
void StopBackendThread ( ) {
stop . request_stop ( ) ;
backend_thread . join ( ) ;
}
Entry CreateEntry ( Class log_class , Level log_level , const char * filename , unsigned int line_nr ,
Entry CreateEntry ( Class log_class , Level log_level , const char * filename , unsigned int line_nr ,
const char * function , std : : string & & message ) const {
const char * function , std : : string & & message ) const {
using std : : chrono : : duration_cast ;
using std : : chrono : : duration_cast ;
@ -283,8 +276,7 @@ private:
ColorConsoleBackend color_console_backend { } ;
ColorConsoleBackend color_console_backend { } ;
FileBackend file_backend ;
FileBackend file_backend ;
std : : stop_source stop ;
std : : jthread backend_thread ;
std : : thread backend_thread ;
MPSCQueue < Entry , true > message_queue { } ;
MPSCQueue < Entry , true > message_queue { } ;
std : : chrono : : steady_clock : : time_point time_origin { std : : chrono : : steady_clock : : now ( ) } ;
std : : chrono : : steady_clock : : time_point time_origin { std : : chrono : : steady_clock : : now ( ) } ;
} ;
} ;