Migrate to parking_lot
This commit is contained in:
1 parent
bf805b79e5
commit
66f8a83dec
13 files changed
+85
-73
No files matched your search
+6
-5
@@ -21,7 +21,8 @@ use rusqlite::Connection;
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::io::BufReader;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::Arc;
|
||||
use parking_lot::Mutex;
|
||||
use tokio::task::spawn_blocking;
|
||||
use zip::ZipArchive;
|
||||
|
||||
@@ -141,7 +142,7 @@ impl NavigatedPage<ImportMessage> for ImportState {
|
||||
back_overlay(
|
||||
{
|
||||
if let Some(value) = &self.progress {
|
||||
column![progress_bar(0f32..=1f32, *value.lock().unwrap()),]
|
||||
column![progress_bar(0f32..=1f32, *value.lock()),]
|
||||
.spacing(QUARTER_SPACING)
|
||||
.into()
|
||||
} else {
|
||||
@@ -444,7 +445,7 @@ impl ImportState {
|
||||
name: group.name.clone(),
|
||||
};
|
||||
{
|
||||
let state = state.lock().unwrap();
|
||||
let state = state.lock();
|
||||
add_group(&mut group_entity, &state.connection);
|
||||
}
|
||||
|
||||
@@ -480,14 +481,14 @@ impl ImportState {
|
||||
words_list.push(word);
|
||||
}
|
||||
|
||||
let mut state = state.lock().unwrap();
|
||||
let mut state = state.lock();
|
||||
let connection = &mut state.connection;
|
||||
let mut index = 0;
|
||||
let total_len = words_list.len() as f32 / 1024.0;
|
||||
for word in &mut words_list.chunks_mut(1024) {
|
||||
add_words(word, connection);
|
||||
index += 1;
|
||||
let mut progress = progress.lock().unwrap();
|
||||
let mut progress = progress.lock();
|
||||
*progress = index as f32 / total_len;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user