Skip to content

Commit

Permalink
Rename some types
Browse files Browse the repository at this point in the history
  • Loading branch information
OscartGiles committed Jul 19, 2024
1 parent 551034b commit 67bc63c
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ pub enum Message {
},
}

pub struct BackgroundActorState {
pub struct TaskManagerState {
abort_handles: HashMap<tokio::task::Id, AbortHandle>,
tasks: JoinSet<()>,
}

impl BackgroundActorState {
impl TaskManagerState {
pub fn new() -> Self {
Self {
abort_handles: HashMap::new(),
Expand All @@ -34,17 +34,17 @@ impl BackgroundActorState {
}
}

impl Default for BackgroundActorState {
impl Default for TaskManagerState {
fn default() -> Self {
Self::new()
}
}

pub struct BackgroundActor;
pub struct BuildTaskManager;

impl Actor for BackgroundActor {
impl Actor for BuildTaskManager {
type Message = Message;
type State = BackgroundActorState;
type State = TaskManagerState;

async fn handle(&self, message: Self::Message, state: &mut Self::State) {
match message {
Expand Down Expand Up @@ -112,10 +112,10 @@ impl Actor for BackgroundActor {
}
}

pub struct BackgroundActorAddr(pub Addr<BackgroundActor>);
pub struct BackgroundActorAddr(pub Addr<BuildTaskManager>);

impl From<Addr<BackgroundActor>> for BackgroundActorAddr {
fn from(addr: Addr<BackgroundActor>) -> Self {
impl From<Addr<BuildTaskManager>> for BackgroundActorAddr {
fn from(addr: Addr<BuildTaskManager>) -> Self {
Self(addr)
}
}
Expand Down Expand Up @@ -144,7 +144,7 @@ impl BackgroundActorAddr {
#[tokio::test]
async fn test_background_worker() {
let (addr, handle): (BackgroundActorAddr, _) =
Actor::spawn(BackgroundActor, BackgroundActorState::new());
Actor::spawn(BuildTaskManager, TaskManagerState::new());

let first_build_id = addr.build().await;
let _second_build_id = addr.build().await;
Expand Down

0 comments on commit 67bc63c

Please sign in to comment.