nautechsystems / nautilus_trader

A high-performance algorithmic trading platform and event-driven backtester
https://nautilustrader.io
GNU Lesser General Public License v3.0
1.7k stars 398 forks source link

Network clients can use `AtomicBool` instead of `<Arc<Mutex<bool>>` #1732

Closed twitu closed 1 day ago

twitu commented 1 week ago

Enhancement Request

The nautilus websocket and socket clients uses an Arc<Mutex<bool>> to syncronize between sender and receiver ends of the stream, particularly for when to disconnect. While Arc Mutex works, AtomicBool is the perfect fit for the role. ^1

Changing the type of the disconnect_mode field in websocket.rs and socket.rs should lead the type system to show all the places where changes are needed.