Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

refactor the way tasks are scheduled in event-loop #8186

Closed
debris opened this issue Mar 22, 2018 · 3 comments
Closed

refactor the way tasks are scheduled in event-loop #8186

debris opened this issue Mar 22, 2018 · 3 comments
Labels
F6-refactor 📚 Code needs refactoring. M4-core ⛓ Core client code / Rust. P5-sometimesoon 🌲 Issue is worth doing soon.
Milestone

Comments

@debris
Copy link
Collaborator

debris commented Mar 22, 2018

after #8185

Current design requires us to define all tasks types in a single place in ClientIoMessage. It makes it difficult to modularize ethcore . Let's think how we could refactor that so tasks could be scheduled without the need of defining them in a single place.

cc @tomaka @0x7CFE

@debris debris added F6-refactor 📚 Code needs refactoring. P5-sometimesoon 🌲 Issue is worth doing soon. M4-core ⛓ Core client code / Rust. labels Mar 22, 2018
@5chdn 5chdn added this to the 1.11 milestone Mar 23, 2018
@5chdn 5chdn modified the milestones: 1.11, 1.12 Apr 24, 2018
@tomaka
Copy link
Contributor

tomaka commented May 21, 2018

Ideally the long-term plan would be to remove the current ethcore_io crate and use futures and streams.
If that happens, each individual message could have its own stream.

@0x7CFE
Copy link
Contributor

0x7CFE commented Jun 14, 2018

@debris Recently I was skimming through a blog post describing Actix API. Maybe we may use something similar.

The key idea is that instead of huge enums messages and handlers may be defined as trait impls:

use actix::prelude::*;

// `PlusOne` message implementation

struct PlusOne;

impl Message for PlusOne {
    type Result = u32;
}

// `CounterActor` implementation

struct CounterActor {
    count: u32,
}

impl CounterActor {
    pub fn new() -> CounterActor {
        CounterActor { count: 0 }
    }
}

impl Actor for CounterActor {
    type Context = Context<Self>;
}

impl Handler<PlusOne> for CounterActor {
    type Result = u32;

    fn handle(&mut self, _msg: PlusOne, _ctx: &mut Context<Self>) -> u32 {
        self.count += 1;
        self.count
    }
}

That way code would be organized more naturally.

@5chdn 5chdn modified the milestones: 2.0, 2.1 Jul 17, 2018
@5chdn 5chdn modified the milestones: 2.1, 2.2 Sep 11, 2018
@5chdn 5chdn modified the milestones: 2.2, 2.3 Oct 29, 2018
@5chdn 5chdn modified the milestones: 2.3, 2.4 Jan 10, 2019
@5chdn 5chdn modified the milestones: 2.4, 2.5 Feb 21, 2019
@soc1c soc1c modified the milestones: 2.5, 2.6 Apr 2, 2019
@ordian ordian modified the milestones: 2.6, 2.7 Jul 12, 2019
@adria0
Copy link

adria0 commented Jul 27, 2020

Closing the issue due to its stale state

@adria0 adria0 closed this as completed Jul 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
F6-refactor 📚 Code needs refactoring. M4-core ⛓ Core client code / Rust. P5-sometimesoon 🌲 Issue is worth doing soon.
Projects
None yet
Development

No branches or pull requests

7 participants