This commit is contained in:
sxyazi 2023-12-29 01:34:01 +08:00
parent 5962c678a0
commit a9e8c9aa92
No known key found for this signature in database
8 changed files with 58 additions and 21 deletions

View file

@ -10,6 +10,17 @@ pub enum FileOp {
Trash(FileOpTrash),
}
impl FileOp {
pub fn id(&self) -> usize {
match self {
Self::Paste(op) => op.id,
Self::Link(op) => op.id,
Self::Delete(op) => op.id,
Self::Trash(op) => op.id,
}
}
}
#[derive(Clone, Debug)]
pub struct FileOpPaste {
pub id: usize,

View file

@ -2,6 +2,7 @@
mod blocker;
mod file;
mod op;
mod plugin;
mod preload;
mod process;
@ -10,6 +11,7 @@ mod scheduler;
mod task;
pub use blocker::*;
pub use op::*;
pub use running::*;
pub use scheduler::*;
pub use task::*;

18
yazi-scheduler/src/op.rs Normal file
View file

@ -0,0 +1,18 @@
#[derive(Debug)]
pub enum TaskOp {
File(Box<crate::file::FileOp>),
Plugin(Box<crate::plugin::PluginOp>),
Preload(Box<crate::preload::PreloadOp>),
Process(Box<crate::process::ProcessOp>),
}
impl TaskOp {
pub fn id(&self) -> usize {
match self {
TaskOp::File(op) => op.id(),
TaskOp::Plugin(op) => op.id(),
TaskOp::Preload(op) => op.id(),
TaskOp::Process(op) => op.id(),
}
}
}

View file

@ -3,6 +3,14 @@ pub enum PluginOp {
Entry(PluginOpEntry),
}
impl PluginOp {
pub fn id(&self) -> usize {
match self {
Self::Entry(op) => op.id,
}
}
}
#[derive(Clone, Debug)]
pub struct PluginOpEntry {
pub id: usize,

View file

@ -8,6 +8,15 @@ pub enum PreloadOp {
Size(PreloadOpSize),
}
impl PreloadOp {
pub fn id(&self) -> usize {
match self {
Self::Rule(op) => op.id,
Self::Size(op) => op.id,
}
}
}
#[derive(Clone, Debug)]
pub struct PreloadOpRule {
pub id: usize,

View file

@ -1,10 +1,10 @@
use std::{collections::{BTreeMap, BTreeSet, HashMap}, sync::Arc};
use std::collections::{BTreeMap, BTreeSet, HashMap};
use anyhow::Result;
use parking_lot::RwLock;
use tokio::sync::mpsc;
use tracing::error;
use yazi_shared::{fs::{calculate_size, FilesOp, Url}, Throttle};
use yazi_shared::fs::{calculate_size, FilesOp, Url};
use super::{PreloadOpRule, PreloadOpSize};
use crate::TaskProg;

View file

@ -8,6 +8,14 @@ pub enum ProcessOp {
Open(ProcessOpOpen),
}
impl ProcessOp {
pub fn id(&self) -> usize {
match self {
Self::Open(op) => op.id,
}
}
}
#[derive(Debug)]
pub struct ProcessOpOpen {
pub id: usize,

View file

@ -58,25 +58,6 @@ impl From<&Task> for TaskSummary {
}
}
#[derive(Debug)]
pub enum TaskOp {
File(Box<crate::file::FileOp>),
Plugin(Box<crate::plugin::PluginOp>),
Preload(Box<crate::preload::PreloadOp>),
Process(Box<crate::process::ProcessOp>),
}
impl TaskOp {
pub fn id(&self) {
match self {
TaskOp::File(op) => todo!(),
TaskOp::Plugin(op) => todo!(),
TaskOp::Preload(_) => todo!(),
TaskOp::Process(_) => todo!(),
}
}
}
#[derive(Debug)]
pub enum TaskProg {
// id, size