Skip to content

Commit

Permalink
Small scheduler cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleragreen committed Sep 13, 2023
1 parent 19ac70e commit 5ffdc09
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions tulsa/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,23 @@ use crate::model::{AsyncTask, Operation, SyncTask};

struct AsyncScheduler {
tasks: HashMap<usize, TaskJoinHandle<()>>,
num_runtime_threads: usize,
}

impl AsyncScheduler {
fn new() -> Self {
AsyncScheduler {
tasks: HashMap::new(),
num_runtime_threads: 1,
}
}

fn listen(&mut self, receiver: Receiver<AsyncTask>) {
println!("AsyncScheduler initialized.");

let num_threads = 1;
let runtime = TokioBuilder::new_multi_thread()
.enable_all()
.worker_threads(num_threads)
.worker_threads(self.num_runtime_threads)
.thread_name("scheduler-runtime")
.build()
.unwrap();
Expand Down Expand Up @@ -58,12 +65,6 @@ impl AsyncScheduler {
}
}
}

fn new() -> Self {
AsyncScheduler {
tasks: HashMap::new(),
}
}
}

struct TaskRunner {
Expand Down Expand Up @@ -130,6 +131,12 @@ struct ThreadScheduler {
}

impl ThreadScheduler {
fn new() -> Self {
ThreadScheduler {
tasks: Arc::new(Mutex::new(Vec::<TaskRunner>::new())),
}
}

fn listen(&mut self, receiver: Receiver<SyncTask>) {
println!("ThreadScheduler initialized.");

Expand Down Expand Up @@ -176,12 +183,6 @@ impl ThreadScheduler {
}
}
}

fn new() -> Self {
ThreadScheduler {
tasks: Arc::new(Mutex::new(Vec::<TaskRunner>::new())),
}
}
}

pub fn init_async(receiver: Receiver<AsyncTask>) {
Expand Down

0 comments on commit 5ffdc09

Please sign in to comment.