workaround for vec2seq len issue
This commit is contained in:
parent
8e36e1c2fd
commit
e7d1763369
2 changed files with 12 additions and 6 deletions
|
@ -34,13 +34,18 @@ where T: Clone + Send + Sync + 'static
|
||||||
data: Vec<T>,
|
data: Vec<T>,
|
||||||
port: InnerViewPort<RwLock<Vec<T>>>
|
port: InnerViewPort<RwLock<Vec<T>>>
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let data = Arc::new(RwLock::new(data));
|
let mut b = VecBuffer::new(port);
|
||||||
port.set_view(Some(data.clone()));
|
for x in data.into_iter() {
|
||||||
VecBuffer { data, cast: port.get_broadcast() }
|
b.push(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
b
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(port: InnerViewPort<RwLock<Vec<T>>>) -> Self {
|
pub fn new(port: InnerViewPort<RwLock<Vec<T>>>) -> Self {
|
||||||
VecBuffer::with_data(Vec::new(), port)
|
let data = Arc::new(RwLock::new(Vec::new()));
|
||||||
|
port.set_view(Some(data.clone()));
|
||||||
|
VecBuffer { data, cast: port.get_broadcast() }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_diff(&mut self, diff: VecDiff<T>) {
|
pub fn apply_diff(&mut self, diff: VecDiff<T>) {
|
||||||
|
|
|
@ -43,13 +43,14 @@ where T: Clone + Send + Sync + 'static {
|
||||||
fn reset(&mut self, view: Option<Arc<RwLock<Vec<T>>>>) {
|
fn reset(&mut self, view: Option<Arc<RwLock<Vec<T>>>>) {
|
||||||
let old_len = self.cur_len;
|
let old_len = self.cur_len;
|
||||||
self.data = view;
|
self.data = view;
|
||||||
self.cur_len =
|
self.cur_len = 0;
|
||||||
|
/*
|
||||||
if let Some(data) = self.data.as_ref() {
|
if let Some(data) = self.data.as_ref() {
|
||||||
data.read().unwrap().len()
|
data.read().unwrap().len()
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
self.cast.notify_each(0 .. std::cmp::max(old_len, self.cur_len));
|
self.cast.notify_each(0 .. std::cmp::max(old_len, self.cur_len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue