put crossbeam dep behind feature gate
This commit is contained in:
parent
769f5be913
commit
b74bfea7dd
@ -10,7 +10,7 @@ delegate = "0.8"
|
|||||||
hashbrown = "0.13"
|
hashbrown = "0.13"
|
||||||
heapless = "0.7"
|
heapless = "0.7"
|
||||||
paste = "1.0"
|
paste = "1.0"
|
||||||
dyn-clone = "1.0.9"
|
dyn-clone = "1.0"
|
||||||
embed-doc-image = "0.1"
|
embed-doc-image = "0.1"
|
||||||
|
|
||||||
[dependencies.num-traits]
|
[dependencies.num-traits]
|
||||||
@ -28,6 +28,7 @@ optional = true
|
|||||||
[dependencies.crossbeam-channel]
|
[dependencies.crossbeam-channel]
|
||||||
version= "0.5"
|
version= "0.5"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
optional = true
|
||||||
|
|
||||||
[dependencies.serde]
|
[dependencies.serde]
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
@ -52,6 +53,7 @@ default = ["std"]
|
|||||||
std = ["downcast-rs/std", "alloc", "bus", "postcard/use-std", "crossbeam-channel/std", "serde/std", "spacepackets/std"]
|
std = ["downcast-rs/std", "alloc", "bus", "postcard/use-std", "crossbeam-channel/std", "serde/std", "spacepackets/std"]
|
||||||
alloc = ["serde/alloc", "spacepackets/alloc"]
|
alloc = ["serde/alloc", "spacepackets/alloc"]
|
||||||
serde = ["dep:serde", "spacepackets/serde"]
|
serde = ["dep:serde", "spacepackets/serde"]
|
||||||
|
crossbeam = ["crossbeam-channel"]
|
||||||
heapless = []
|
heapless = []
|
||||||
doc-images = []
|
doc-images = []
|
||||||
|
|
||||||
|
@ -13,10 +13,10 @@
|
|||||||
//! executed. Note that the verification part could also be done in a separate thread.
|
//! executed. Note that the verification part could also be done in a separate thread.
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use std::sync::{Arc, RwLock};
|
//! use std::sync::{Arc, mpsc, RwLock};
|
||||||
//! use std::time::Duration;
|
//! use std::time::Duration;
|
||||||
//! use satrs_core::pool::{LocalPool, PoolCfg, PoolProvider, SharedPool};
|
//! use satrs_core::pool::{LocalPool, PoolCfg, PoolProvider, SharedPool};
|
||||||
//! use satrs_core::pus::verification::{CrossbeamVerifSender, VerificationReporterCfg, VerificationReporterWithSender};
|
//! use satrs_core::pus::verification::{MpscVerifSender, VerificationReporterCfg, VerificationReporterWithSender};
|
||||||
//! use satrs_core::seq_count::SimpleSeqCountProvider;
|
//! use satrs_core::seq_count::SimpleSeqCountProvider;
|
||||||
//! use spacepackets::ecss::PusPacket;
|
//! use spacepackets::ecss::PusPacket;
|
||||||
//! use spacepackets::SpHeader;
|
//! use spacepackets::SpHeader;
|
||||||
@ -28,8 +28,8 @@
|
|||||||
//!
|
//!
|
||||||
//! let pool_cfg = PoolCfg::new(vec![(10, 32), (10, 64), (10, 128), (10, 1024)]);
|
//! let pool_cfg = PoolCfg::new(vec![(10, 32), (10, 64), (10, 128), (10, 1024)]);
|
||||||
//! let shared_tm_pool: SharedPool = Arc::new(RwLock::new(Box::new(LocalPool::new(pool_cfg.clone()))));
|
//! let shared_tm_pool: SharedPool = Arc::new(RwLock::new(Box::new(LocalPool::new(pool_cfg.clone()))));
|
||||||
//! let (verif_tx, verif_rx) = crossbeam_channel::bounded(10);
|
//! let (verif_tx, verif_rx) = mpsc::channel();
|
||||||
//! let sender = CrossbeamVerifSender::new(shared_tm_pool.clone(), verif_tx);
|
//! let sender = MpscVerifSender::new(shared_tm_pool.clone(), verif_tx);
|
||||||
//! let cfg = VerificationReporterCfg::new(TEST_APID, Box::new(SimpleSeqCountProvider::default()), 1, 2, 8).unwrap();
|
//! let cfg = VerificationReporterCfg::new(TEST_APID, Box::new(SimpleSeqCountProvider::default()), 1, 2, 8).unwrap();
|
||||||
//! let mut reporter = VerificationReporterWithSender::new(&cfg , Box::new(sender));
|
//! let mut reporter = VerificationReporterWithSender::new(&cfg , Box::new(sender));
|
||||||
//!
|
//!
|
||||||
@ -93,10 +93,12 @@ pub use alloc_mod::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::seq_count::SequenceCountProvider;
|
use crate::seq_count::SequenceCountProvider;
|
||||||
|
#[cfg(feature = "crossbeam")]
|
||||||
|
pub use stdmod::CrossbeamVerifSender;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub use stdmod::{
|
pub use stdmod::{
|
||||||
CrossbeamVerifSender, MpscVerifSender, SharedStdVerifReporterWithSender,
|
MpscVerifSender, SharedStdVerifReporterWithSender, StdVerifReporterWithSender,
|
||||||
StdVerifReporterWithSender, StdVerifSenderError,
|
StdVerifSenderError,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
|
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
|
||||||
@ -1091,11 +1093,13 @@ mod stdmod {
|
|||||||
|
|
||||||
/// Verification sender with a [crossbeam_channel::Sender] backend.
|
/// Verification sender with a [crossbeam_channel::Sender] backend.
|
||||||
/// It implements the [EcssTmSender] trait to be used as PUS Verification TM sender
|
/// It implements the [EcssTmSender] trait to be used as PUS Verification TM sender
|
||||||
|
#[cfg(feature = "crossbeam")]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct CrossbeamVerifSender {
|
pub struct CrossbeamVerifSender {
|
||||||
base: StdSenderBase<crossbeam_channel::Sender<StoreAddr>>,
|
base: StdSenderBase<crossbeam_channel::Sender<StoreAddr>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "crossbeam")]
|
||||||
impl CrossbeamVerifSender {
|
impl CrossbeamVerifSender {
|
||||||
pub fn new(tm_store: SharedPool, tx: crossbeam_channel::Sender<StoreAddr>) -> Self {
|
pub fn new(tm_store: SharedPool, tx: crossbeam_channel::Sender<StoreAddr>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@ -1105,6 +1109,7 @@ mod stdmod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//noinspection RsTraitImplementation
|
//noinspection RsTraitImplementation
|
||||||
|
#[cfg(feature = "crossbeam")]
|
||||||
impl EcssTmSender for CrossbeamVerifSender {
|
impl EcssTmSender for CrossbeamVerifSender {
|
||||||
type Error = StdVerifSenderError;
|
type Error = StdVerifSenderError;
|
||||||
|
|
||||||
@ -1115,7 +1120,10 @@ mod stdmod {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Are those really necessary? Check with test..
|
||||||
|
#[cfg(feature = "crossbeam")]
|
||||||
unsafe impl Sync for CrossbeamVerifSender {}
|
unsafe impl Sync for CrossbeamVerifSender {}
|
||||||
|
#[cfg(feature = "crossbeam")]
|
||||||
unsafe impl Send for CrossbeamVerifSender {}
|
unsafe impl Send for CrossbeamVerifSender {}
|
||||||
|
|
||||||
impl<S: SendBackend + Clone + 'static> EcssTmSender for StdSenderBase<S> {
|
impl<S: SendBackend + Clone + 'static> EcssTmSender for StdSenderBase<S> {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#[cfg(feature = "crossbeam")]
|
||||||
|
pub mod crossbeam_test {
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use satrs_core::pool::{LocalPool, PoolCfg, PoolProvider, SharedPool};
|
use satrs_core::pool::{LocalPool, PoolCfg, PoolProvider, SharedPool};
|
||||||
use satrs_core::pus::verification::{
|
use satrs_core::pus::verification::{
|
||||||
@ -45,7 +47,8 @@ fn test_shared_reporter() {
|
|||||||
let shared_tc_pool_1 = shared_tc_pool_0.clone();
|
let shared_tc_pool_1 = shared_tc_pool_0.clone();
|
||||||
let (tx, rx) = crossbeam_channel::bounded(5);
|
let (tx, rx) = crossbeam_channel::bounded(5);
|
||||||
let sender = CrossbeamVerifSender::new(shared_tm_pool.clone(), tx.clone());
|
let sender = CrossbeamVerifSender::new(shared_tm_pool.clone(), tx.clone());
|
||||||
let mut reporter_with_sender_0 = VerificationReporterWithSender::new(&cfg, Box::new(sender));
|
let mut reporter_with_sender_0 =
|
||||||
|
VerificationReporterWithSender::new(&cfg, Box::new(sender));
|
||||||
let mut reporter_with_sender_1 = reporter_with_sender_0.clone();
|
let mut reporter_with_sender_1 = reporter_with_sender_0.clone();
|
||||||
// For test purposes, we retrieve the request ID from the TCs and pass them to the receiver
|
// For test purposes, we retrieve the request ID from the TCs and pass them to the receiver
|
||||||
// tread.
|
// tread.
|
||||||
@ -155,10 +158,11 @@ fn test_shared_reporter() {
|
|||||||
tm_len = slice.len();
|
tm_len = slice.len();
|
||||||
tm_buf[0..tm_len].copy_from_slice(slice);
|
tm_buf[0..tm_len].copy_from_slice(slice);
|
||||||
}
|
}
|
||||||
let (pus_tm, _) =
|
let (pus_tm, _) = PusTm::from_bytes(&tm_buf[0..tm_len], 7)
|
||||||
PusTm::from_bytes(&tm_buf[0..tm_len], 7).expect("Error reading verification TM");
|
.expect("Error reading verification TM");
|
||||||
let req_id = RequestId::from_bytes(
|
let req_id = RequestId::from_bytes(
|
||||||
&pus_tm.source_data().expect("Invalid TM source data")[0..RequestId::SIZE_AS_BYTES],
|
&pus_tm.source_data().expect("Invalid TM source data")
|
||||||
|
[0..RequestId::SIZE_AS_BYTES],
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if !verif_map.contains_key(&req_id) {
|
if !verif_map.contains_key(&req_id) {
|
||||||
@ -191,3 +195,4 @@ fn test_shared_reporter() {
|
|||||||
verif_sender_1.join().expect("Joining thread 1 failed");
|
verif_sender_1.join().expect("Joining thread 1 failed");
|
||||||
verif_receiver.join().expect("Joining thread 2 failed");
|
verif_receiver.join().expect("Joining thread 2 failed");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user