Skip to content

Commit

Permalink
Add test of pined and named processor thread.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholassm committed Jun 24, 2024
1 parent b8595ee commit 13406d0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,29 @@ mod tests {
assert_eq!(result, [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]);
}

#[cfg_attr(miri, ignore)]
#[test]
fn spsc_disruptor_with_pined_and_named_thread() {
let (s, r) = mpsc::channel();
let processor = move |e: &Event, _, _| {
s.send(e.num).expect("Should be able to send.");
};
let mut producer = build_single_producer(8, factory(), BusySpin)
.pined_at_core(0).thread_named("my-processor").handle_events_with(processor)
.build();

thread::scope(|s| {
s.spawn(move || {
for i in 0..10 {
producer.publish(|e| e.num = i*i );
}
});
});

let result: Vec<_> = r.iter().collect();
assert_eq!(result, [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]);
}

#[test]
fn spsc_disruptor_with_batch_publication() {
let (s, r) = mpsc::channel();
Expand Down

0 comments on commit 13406d0

Please sign in to comment.