disable code causing deadlock

This commit is contained in:
Michael Sippel 2021-01-16 15:31:37 +01:00
parent 28970658c0
commit 981ec3438f
Signed by: senvas
GPG key ID: F96CF119C34B64A6
3 changed files with 40 additions and 45 deletions

View file

@ -17,6 +17,7 @@ pub trait IndexView<Key> : View<Msg = Key> {
fn get(&self, key: &Key) -> Self::Item;
// todo: AreaIterator enum to switch between Allocated and Procedural area
fn area(&self) -> Option<Vec<Key>> {
None
}

View file

@ -33,28 +33,6 @@ use {
}
};
struct TermLabel(String);
impl ImplIndexView for TermLabel {
type Key = Point2<i16>;
type Value = Option<TerminalAtom>;
fn get(&self, pos: &Point2<i16>) -> Option<TerminalAtom> {
if pos.y == 5 {
Some(TerminalAtom::from(self.0.chars().nth(pos.x as usize)?))
} else {
None
}
}
fn area(&self) -> Option<Vec<Point2<i16>>> {
Some(
GridWindowIterator::from(
Point2::new(0, 5) .. Point2::new(self.0.chars().count() as i16, 6)
).collect()
)
}
}
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
#[async_std::main]
@ -77,7 +55,6 @@ async fn main() {
let window_size_port = ViewPort::new();
let window_size = SingletonBuffer::new(Vector2::new(0, 0), window_size_port.inner());
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
// string editor
let edit_port = ViewPort::<dyn TerminalView>::new();
@ -103,7 +80,6 @@ async fn main() {
edit_o.write().unwrap().set_offset(Vector2::new(40, 4));
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
// stupid label animation
let label_port = ViewPort::<dyn TerminalView>::new();
@ -133,7 +109,6 @@ async fn main() {
let vec_seq_port = ViewPort::new();
let vec_seq = sequence::VecSequence::new(vec_seq_port.inner());
vec_port.add_observer(vec_seq.clone());
let vec_term_view = vec_seq_port.outer()
.to_index()
.map_key(
@ -163,12 +138,10 @@ async fn main() {
TerminalEvent::Input(Event::Key(Key::Home)) => editor.goto(0),
TerminalEvent::Input(Event::Key(Key::End)) => editor.goto_end(),
TerminalEvent::Input(Event::Key(Key::Char('\n'))) => {},
TerminalEvent::Input(Event::Key(Key::Char(c))) => {editor.insert(c); vec_buf.push(c); },
TerminalEvent::Input(Event::Key(Key::Char(c))) => editor.insert(c),
TerminalEvent::Input(Event::Key(Key::Delete)) => editor.delete(),
TerminalEvent::Input(Event::Key(Key::Backspace)) => { editor.prev(); editor.delete(); },
TerminalEvent::Input(Event::Key(Key::Ctrl('c'))) => {
break
}
TerminalEvent::Input(Event::Key(Key::Ctrl('c'))) => break,
_ => {}
}
}
@ -183,7 +156,6 @@ async fn main() {
}
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
struct Checkerboard;
impl ImplIndexView for Checkerboard {
type Key = Point2<i16>;
@ -209,7 +181,29 @@ impl ImplIndexView for Checkerboard {
}
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
struct TermLabel(String);
impl ImplIndexView for TermLabel {
type Key = Point2<i16>;
type Value = Option<TerminalAtom>;
fn get(&self, pos: &Point2<i16>) -> Option<TerminalAtom> {
if pos.y == 5 {
Some(TerminalAtom::from(self.0.chars().nth(pos.x as usize)?))
} else {
None
}
}
fn area(&self) -> Option<Vec<Point2<i16>>> {
Some(
GridWindowIterator::from(
Point2::new(0, 5) .. Point2::new(self.0.chars().count() as i16, 6)
).collect()
)
}
}
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
struct ScrambleBackground;
impl ImplIndexView for ScrambleBackground {
type Key = Point2<i16>;
@ -225,7 +219,6 @@ impl ImplIndexView for ScrambleBackground {
fn area(&self) -> Option<Vec<Point2<i16>>> {
None
//Some(Point2::new(0,0) .. Point2::new(50,30))
}
}

View file

@ -24,24 +24,25 @@ impl Observer<dyn TerminalView> for CompositeLayer {
let comp = self.comp.upgrade().unwrap();
let mut c = comp.write().unwrap();
{
let old_view = c.layers[&self.idx].1.clone();
c.layers.get_mut(&self.idx).unwrap().1 = view.clone();
let mut v = &mut c.layers.get_mut(&self.idx).unwrap().1;
let old_view = v.clone();
*v = view.clone();
drop(v);
if let Some(old_view) = old_view {
if let Some(area) = old_view.area() {
c.cast.notify_each(area);
}
}
//todo: fixme: why does this cause a deadlock?
//c.update_range();
if let Some(view) = view.as_ref() {
if let Some(area) = view.area() {
c.cast.notify_each(area);
}
if let Some(old_view) = old_view {
if let Some(area) = old_view.area() {
c.cast.notify_each(area);
}
}
c.update_range();
if let Some(view) = view.as_ref() {
if let Some(area) = view.area() {
c.cast.notify_each(area);
}
}
}
fn notify(&self, pos: &Point2<i16>) {
@ -131,7 +132,7 @@ impl TerminalCompositor {
TerminalCompositeView {
idx_count: 0,
layers: HashMap::new(),
area: Some(Vec::new()),
area: None,//Some(Vec::new()),
cast: port.get_broadcast()
}
));