11//! This handles communication between clients and the server
22
33use std:: net:: SocketAddr ;
4+ use std:: sync:: LazyLock ;
45use std:: time:: Duration ;
56
67use tokio:: sync:: mpsc:: { channel, Receiver , Sender } ;
@@ -9,7 +10,6 @@ use tokio::time::sleep;
910
1011use libstrawberry:: stbchat:: object:: User ;
1112use libstrawberry:: string:: escape_ansi;
12- use lazy_static:: lazy_static;
1313
1414use crate :: system_core:: commands:: run_command;
1515use crate :: system_core:: internals:: { MessageToClient , MessageToServer } ;
@@ -140,6 +140,7 @@ pub async fn send_to_all(what: MessageToClient, authed_only: bool) {
140140 }
141141}
142142
143+ #[ allow( clippy:: cognitive_complexity) ]
143144pub async fn core_thread ( watchdog_tx : Sender < ( ) > ) {
144145 RUNTIME_LOGGER . info ( format ! ( "Starting core thread ({})" , CORE_VERSION . clone( ) ) ) ;
145146
@@ -305,8 +306,6 @@ fn send_to_hook_sync(who: User, what: Event) -> bool {
305306 } )
306307}
307308
308- lazy_static ! {
309- pub static ref CLIENTS : RwLock <Vec <Connection >> = RwLock :: new( Vec :: new( ) ) ;
310- static ref EVENT_HOOKS : RwLock <Vec <EventHook >> = RwLock :: new( Vec :: new( ) ) ;
311- pub static ref STATUS : RwLock <UserStatus > = RwLock :: new( UserStatus :: new( ) ) ;
312- }
309+ pub static CLIENTS : LazyLock < RwLock < Vec < Connection > > > = LazyLock :: new ( || RwLock :: new ( Vec :: new ( ) ) ) ;
310+ static EVENT_HOOKS : LazyLock < RwLock < Vec < EventHook > > > = LazyLock :: new ( || RwLock :: new ( Vec :: new ( ) ) ) ;
311+ pub static STATUS : LazyLock < RwLock < UserStatus > > = LazyLock :: new ( || RwLock :: new ( UserStatus :: new ( ) ) ) ;
0 commit comments