make thread safe connection more thread safe
Co-Authored-By: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
parent
9cd6894dc5
commit
a29ccb4ff8
12 changed files with 196 additions and 124 deletions
|
@ -4,6 +4,10 @@ use std::sync::mpsc::Sender;
|
|||
use parking_lot::Mutex;
|
||||
use thread_local::ThreadLocal;
|
||||
|
||||
/// Unbounded standard library sender which is stored per thread to get around
|
||||
/// the lack of sync on the standard library version while still being unbounded
|
||||
/// Note: this locks on the cloneable sender, but its done once per thread, so it
|
||||
/// shouldn't result in too much contention
|
||||
pub struct UnboundedSyncSender<T: Send> {
|
||||
clonable_sender: Mutex<Sender<T>>,
|
||||
local_senders: ThreadLocal<Sender<T>>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue