Add rust lint CI job.
All checks were successful
Check / Check Rust (pull_request) Successful in 21s
All checks were successful
Check / Check Rust (pull_request) Successful in 21s
This commit is contained in:
parent
311755c812
commit
4d9c237651
30 changed files with 177 additions and 108 deletions
|
|
@ -48,7 +48,7 @@ struct TaskWaker {
|
|||
}
|
||||
|
||||
impl TaskWaker {
|
||||
fn new(task_id: TaskId, task_queue: Arc<Mutex<VecDeque<TaskId>>>) -> Waker {
|
||||
fn create_waker(task_id: TaskId, task_queue: Arc<Mutex<VecDeque<TaskId>>>) -> Waker {
|
||||
Waker::from(Arc::new(TaskWaker {
|
||||
task_id,
|
||||
task_queue,
|
||||
|
|
@ -69,6 +69,7 @@ impl Wake for TaskWaker {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Executor {
|
||||
tasks: Arc<Mutex<BTreeMap<TaskId, Task>>>,
|
||||
// TODO: Consider a better datastructure for this.
|
||||
|
|
@ -78,11 +79,7 @@ pub struct Executor {
|
|||
|
||||
impl Executor {
|
||||
pub fn new() -> Executor {
|
||||
Executor {
|
||||
tasks: Arc::new(Mutex::new(BTreeMap::new())),
|
||||
task_queue: Arc::new(Mutex::new(VecDeque::new())),
|
||||
waker_cache: BTreeMap::new(),
|
||||
}
|
||||
Executor::default()
|
||||
}
|
||||
|
||||
pub fn spawn(&mut self, task: Task) {
|
||||
|
|
@ -100,7 +97,7 @@ impl Executor {
|
|||
let waker = self
|
||||
.waker_cache
|
||||
.entry(task_id)
|
||||
.or_insert_with(|| TaskWaker::new(task_id, self.task_queue.clone()));
|
||||
.or_insert_with(|| TaskWaker::create_waker(task_id, self.task_queue.clone()));
|
||||
let mut ctx = Context::from_waker(waker);
|
||||
match task.poll(&mut ctx) {
|
||||
Poll::Ready(()) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue