Skip to content

Commit 34f287d

Browse files
committed
Remove Event
Signed-off-by: Moritz Hoffmann <[email protected]>
1 parent b4030e9 commit 34f287d

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

communication/src/allocator/counters.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::rc::Rc;
44
use std::cell::RefCell;
55

66
use crate::{Push, Pull};
7-
use crate::allocator::Event;
87

98
/// The push half of an intra-thread channel.
109
pub struct Pusher<T, P: Push<T>> {
@@ -58,15 +57,15 @@ use crossbeam_channel::Sender;
5857
pub struct ArcPusher<T, P: Push<T>> {
5958
index: usize,
6059
// count: usize,
61-
events: Sender<(usize, Event)>,
60+
events: Sender<usize>,
6261
pusher: P,
6362
phantom: ::std::marker::PhantomData<T>,
6463
buzzer: crate::buzzer::Buzzer,
6564
}
6665

6766
impl<T, P: Push<T>> ArcPusher<T, P> {
6867
/// Wraps a pusher with a message counter.
69-
pub fn new(pusher: P, index: usize, events: Sender<(usize, Event)>, buzzer: crate::buzzer::Buzzer) -> Self {
68+
pub fn new(pusher: P, index: usize, events: Sender<usize>, buzzer: crate::buzzer::Buzzer) -> Self {
7069
ArcPusher {
7170
index,
7271
// count: 0,
@@ -98,7 +97,7 @@ impl<T, P: Push<T>> Push<T> for ArcPusher<T, P> {
9897
// and finally awaken the thread. Other orders are defective when
9998
// multiple threads are involved.
10099
self.pusher.push(element);
101-
let _ = self.events.send((self.index, Event::Pushed(1)));
100+
let _ = self.events.send(self.index);
102101
// TODO : Perhaps this shouldn't be a fatal error (e.g. in shutdown).
103102
// .expect("Failed to send message count");
104103
self.buzzer.buzz();

communication/src/allocator/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,3 @@ pub trait Allocate {
9191
thread::Thread::new_from(identifier, self.events().clone())
9292
}
9393
}
94-
95-
/// A communication channel event.
96-
pub enum Event {
97-
/// A number of messages pushed into the channel.
98-
Pushed(usize),
99-
/// A number of messages pulled from the channel.
100-
Pulled(usize),
101-
}

communication/src/allocator/process.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::collections::{HashMap};
99
use crossbeam_channel::{Sender, Receiver};
1010

1111
use crate::allocator::thread::{ThreadBuilder};
12-
use crate::allocator::{Allocate, AllocateBuilder, Event, Thread};
12+
use crate::allocator::{Allocate, AllocateBuilder, Thread};
1313
use crate::{Push, Pull, Message};
1414
use crate::buzzer::Buzzer;
1515

@@ -25,8 +25,8 @@ pub struct ProcessBuilder {
2525
buzzers_send: Vec<Sender<Buzzer>>,
2626
buzzers_recv: Vec<Receiver<Buzzer>>,
2727

28-
counters_send: Vec<Sender<(usize, Event)>>,
29-
counters_recv: Receiver<(usize, Event)>,
28+
counters_send: Vec<Sender<usize>>,
29+
counters_recv: Receiver<usize>,
3030
}
3131

3232
impl AllocateBuilder for ProcessBuilder {
@@ -63,8 +63,8 @@ pub struct Process {
6363
// below: `Box<Any+Send>` is a `Box<Vec<Option<(Vec<Sender<T>>, Receiver<T>)>>>`
6464
channels: Arc<Mutex<HashMap</* channel id */ usize, Box<dyn Any+Send>>>>,
6565
buzzers: Vec<Buzzer>,
66-
counters_send: Vec<Sender<(usize, Event)>>,
67-
counters_recv: Receiver<(usize, Event)>,
66+
counters_send: Vec<Sender<usize>>,
67+
counters_recv: Receiver<usize>,
6868
}
6969

7070
impl Process {
@@ -184,7 +184,7 @@ impl Allocate for Process {
184184

185185
fn receive(&mut self) {
186186
let mut events = self.inner.events().borrow_mut();
187-
while let Ok((index, _event)) = self.counters_recv.try_recv() {
187+
while let Ok(index) = self.counters_recv.try_recv() {
188188
events.push(index);
189189
}
190190
}

0 commit comments

Comments
 (0)