mirror of
https://github.com/callumio/suck.git
synced 2025-12-17 03:29:21 +00:00
Allow for completely lock-free access to Static values, and closed channels.
This commit is contained in:
parent
061a45eaa8
commit
3a3cfa8a3b
6 changed files with 35 additions and 20 deletions
|
|
@ -1,6 +1,9 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
#[cfg(feature = "sync-crossbeam")]
|
||||
use crate::sync::traits::{ChannelError, ChannelReceiver, ChannelSender, ChannelType};
|
||||
use crate::types;
|
||||
use arc_swap::ArcSwap;
|
||||
use crossbeam_channel;
|
||||
|
||||
type CrossbeamSucker<T> =
|
||||
|
|
@ -62,10 +65,10 @@ impl<T> CrossbeamSuck<T> {
|
|||
let (request_tx, request_rx) = CrossbeamChannel::create_request_channel();
|
||||
let (response_tx, response_rx) = CrossbeamChannel::create_response_channel::<T>();
|
||||
|
||||
let state = std::sync::Arc::new(std::sync::Mutex::new(crate::types::ValueSource::None));
|
||||
let state = ArcSwap::new(Arc::new(crate::types::ValueSource::None));
|
||||
|
||||
let sucker = crate::Sucker::new(request_tx, response_rx);
|
||||
let sourcer = crate::Sourcer::new(request_rx, response_tx, std::sync::Arc::clone(&state));
|
||||
let sourcer = crate::Sourcer::new(request_rx, response_tx, state);
|
||||
|
||||
(sucker, sourcer)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue