script to enable/disable no_deadlocks::RwLock instead of std::sync::RwLock

This commit is contained in:
Michael Sippel 2021-03-30 22:47:05 +02:00
parent 0fcf852b72
commit c63fd6d1f2
Signed by: senvas
GPG key ID: F96CF119C34B64A6
22 changed files with 60 additions and 28 deletions

View file

@ -6,6 +6,7 @@ name = "NeStEd"
version = "0.1.0" version = "0.1.0"
[dependencies] [dependencies]
no_deadlocks = "*"
cgmath = "0.17.0" cgmath = "0.17.0"
termion = "1.5.5" termion = "1.5.5"
signal-hook = "0.3.1" signal-hook = "0.3.1"

16
enable_nodeadlock.sh Normal file
View file

@ -0,0 +1,16 @@
#!/bin/sh
enable_no_deadlock() {
for f in $(find src -name *.rs)
do
sed -ibak -E "s/std::sync::RwLock(;|,|$)/no_deadlocks::RwLock\1/g" $f
done
}
disable_no_deadlock() {
for f in $(find src -name *.rs)
do
sed -ibak -E "s/no_deadlocks::RwLock(;|,|$)/std::sync::RwLock\1/g" $f
done
}

View file

@ -1,11 +1,12 @@
use { use {
async_std::stream::StreamExt, async_std::stream::StreamExt,
std::{ std::{
sync::{Arc, RwLock}, sync::Arc,
collections::HashMap, collections::HashMap,
cmp::{min, max} cmp::{min, max}
}, },
cgmath::{Point2, Vector2}, cgmath::{Point2, Vector2},
std::sync::RwLock,
crate::{ crate::{
core::{InnerViewPort, OuterViewPort, Observer, ObserverExt, ObserverBroadcast, ChannelReceiver, ChannelSender}, core::{InnerViewPort, OuterViewPort, Observer, ObserverExt, ObserverBroadcast, ChannelReceiver, ChannelSender},
terminal::{TerminalView, TerminalAtom}, terminal::{TerminalView, TerminalAtom},

View file

@ -1,8 +1,9 @@
use { use {
crate::core::View, crate::core::View,
std::{ std::{
sync::{Arc, Weak, RwLock} sync::{Arc, Weak}
} },
std::sync::RwLock
}; };
/*\ /*\

View file

@ -1,5 +1,7 @@
use { use {
std::sync::{Arc, RwLock}, std::sync::Arc,
std::any::Any,
std::sync::RwLock,
crate::core::{ crate::core::{
View, View,
Observer, Observer,

View file

@ -11,7 +11,8 @@ pub trait View : Send + Sync {
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>> //<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
use std::sync::{Arc, RwLock}; use std::sync::Arc;
use std::sync::RwLock;
impl<V: View + ?Sized> View for RwLock<V> { impl<V: View + ?Sized> View for RwLock<V> {
type Msg = V::Msg; type Msg = V::Msg;

View file

@ -1,8 +1,7 @@
use { use {
std::{ std::sync::Arc,
sync::{Arc, RwLock}
},
cgmath::{Point2, Vector2}, cgmath::{Point2, Vector2},
std::sync::RwLock,
crate::{ crate::{
core::{ core::{
View, View,

View file

@ -1,8 +1,9 @@
pub use { pub use {
std::{ std::{
sync::{Arc, RwLock}, sync::Arc,
boxed::Box boxed::Box
}, },
std::sync::RwLock,
crate::{ crate::{
core::{ core::{
View, View,

View file

@ -1,8 +1,9 @@
pub use { pub use {
std::{ std::{
sync::{Arc, RwLock}, sync::Arc,
boxed::Box boxed::Box
}, },
std::sync::RwLock,
crate::{ crate::{
core::{ core::{
View, View,

View file

@ -4,9 +4,10 @@ pub mod map_key;
use { use {
std::{ std::{
sync::{Arc, RwLock}, sync::Arc,
ops::Deref, ops::Deref,
}, },
std::sync::RwLock,
crate::core::View crate::core::View
}; };

View file

@ -1,8 +1,9 @@
use { use {
std::{ std::{
sync::{Arc, RwLock}, sync::{Arc},
collections::HashSet collections::HashSet
}, },
std::sync::RwLock,
cgmath::Point2, cgmath::Point2,
crate::{ crate::{
core::{ViewPort, Observer, ObserverExt, ObserverBroadcast, InnerViewPort, OuterViewPort}, core::{ViewPort, Observer, ObserverExt, ObserverBroadcast, InnerViewPort, OuterViewPort},

View file

@ -14,9 +14,8 @@ pub mod leveled_term_view;
use { use {
async_std::{task}, async_std::{task},
std::{ std::sync::{Arc},
sync::{Arc, RwLock} std::sync::RwLock,
},
cgmath::{Vector2, Point2}, cgmath::{Vector2, Point2},
termion::event::{Event, Key}, termion::event::{Event, Key},
crate::{ crate::{

View file

@ -2,11 +2,12 @@ use {
std::{ std::{
cmp::{max}, cmp::{max},
any::Any, any::Any,
sync::{Arc, RwLock, Weak} sync::{Arc, Weak},
}, },
async_std::{ async_std::{
stream::StreamExt stream::StreamExt
}, },
std::sync::RwLock,
crate::{ crate::{
core::{View, Observer, ObserverExt, OuterViewPort, channel::{channel, ChannelData, ChannelSender, ChannelReceiver}}, core::{View, Observer, ObserverExt, OuterViewPort, channel::{channel, ChannelData, ChannelSender, ChannelReceiver}},
singleton::{SingletonView}, singleton::{SingletonView},

View file

@ -1,9 +1,10 @@
use { use {
async_std::stream::StreamExt, async_std::stream::StreamExt,
std::{ std::{
sync::{Arc, Weak, RwLock}, sync::{Arc, Weak},
collections::{HashMap, HashSet} collections::{HashMap, HashSet}
}, },
std::sync::RwLock,
crate::{ crate::{
core::{ core::{
View, Observer, ObserverExt, ObserverBroadcast, View, Observer, ObserverExt, ObserverBroadcast,

View file

@ -22,9 +22,10 @@ pub trait SequenceView : View<Msg = usize> {
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>> //<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
use std::{ use std::{
sync::{Arc, RwLock}, sync::Arc,
ops::{Deref} ops::{Deref}
}; };
use std::sync::RwLock;
impl<V: SequenceView + ?Sized> SequenceView for RwLock<V> { impl<V: SequenceView + ?Sized> SequenceView for RwLock<V> {
type Item = V::Item; type Item = V::Item;

View file

@ -1,7 +1,8 @@
use { use {
std::{ std::{
sync::{Arc, RwLock} sync::Arc
}, },
std::sync::RwLock,
crate::{ crate::{
core::{ core::{
View, Observer, ObserverExt, ObserverBroadcast, View, Observer, ObserverExt, ObserverBroadcast,

View file

@ -1,8 +1,9 @@
use { use {
std::{ std::{
sync::{Arc, RwLock}, sync::Arc,
ops::{Deref, DerefMut} ops::{Deref, DerefMut}
}, },
std::sync::RwLock,
crate::{ crate::{
core::{View, Observer, ObserverExt, ObserverBroadcast, ViewPort, InnerViewPort, OuterViewPort}, core::{View, Observer, ObserverExt, ObserverBroadcast, ViewPort, InnerViewPort, OuterViewPort},
sequence::SequenceView, sequence::SequenceView,

View file

@ -1,7 +1,8 @@
use { use {
std::{ std::{
sync::{Arc, RwLock} sync::{Arc}
}, },
std::sync::RwLock,
crate::{ crate::{
core::{ core::{
Observer, Observer,

View file

@ -3,9 +3,10 @@ pub mod buffer;
use { use {
std::{ std::{
sync::{Arc, RwLock}, sync::Arc,
ops::Deref ops::Deref
}, },
std::sync::RwLock,
crate::core::{View} crate::core::{View}
}; };

View file

@ -1,7 +1,5 @@
use { use {
std::{ std::sync::RwLock,
sync::{RwLock}
},
crate::{ crate::{
core::{ViewPort, OuterViewPort}, core::{ViewPort, OuterViewPort},
singleton::{SingletonView, SingletonBuffer}, singleton::{SingletonView, SingletonBuffer},
@ -101,12 +99,13 @@ impl StringEditor {
pub mod insert_view { pub mod insert_view {
use { use {
std::{ std::{
sync::{Arc, RwLock}, sync::Arc,
cmp::{min, max}, cmp::{min, max},
any::Any, any::Any,
collections::HashSet collections::HashSet
}, },
cgmath::Point2, cgmath::Point2,
std::sync::RwLock,
crate::{ crate::{
core::{View, Observer, ObserverExt, ObserverBroadcast, OuterViewPort, InnerViewPort}, core::{View, Observer, ObserverExt, ObserverBroadcast, OuterViewPort, InnerViewPort},
terminal::{TerminalAtom, TerminalStyle, TerminalView}, terminal::{TerminalAtom, TerminalStyle, TerminalView},

View file

@ -1,8 +1,9 @@
use { use {
std::{ std::{
sync::{Arc, Weak, RwLock}, sync::{Arc, Weak},
collections::HashMap collections::HashMap
}, },
std::sync::RwLock,
cgmath::Point2, cgmath::Point2,
crate::{ crate::{
core::{InnerViewPort, OuterViewPort, Observer, ObserverExt, ObserverBroadcast}, core::{InnerViewPort, OuterViewPort, Observer, ObserverExt, ObserverBroadcast},

View file

@ -1,9 +1,10 @@
use { use {
std::{ std::{
sync::{Arc, RwLock}, sync::Arc,
io::{Write, stdout, stdin}, io::{Write, stdout, stdin},
collections::HashSet collections::HashSet
}, },
std::sync::RwLock,
async_std::{ async_std::{
stream::StreamExt, stream::StreamExt,
task task