Skip to content

Commit

Permalink
Fix. Actors allocators
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriano Santos committed Feb 11, 2023
1 parent d31ee57 commit 31fea3e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added Makefile
Empty file.
1 change: 1 addition & 0 deletions spawn-examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ name = "spawn-examples"
version = "0.1.0"

[dependencies]
prost-types = "0.11"
spawn-rs = {path = "../spawn-rs"}
2 changes: 1 addition & 1 deletion spawn-examples/src/joe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use spawn_rs::{
value::Value,
};

struct Joe;
pub struct Joe;

impl Actor for Joe {
fn settings(&mut self) -> ActorSettings {
Expand Down
10 changes: 8 additions & 2 deletions spawn-examples/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
use spawn_rs::Spawn;
extern crate prost_types;

mod joe;

use spawn_rs::spawn::Spawn;

fn main() {
Spawn::new().system("spawn-system")
Spawn::new()
.system("spawn-system".to_string())
.port(8091)
.add_actor(Box::new(joe::Joe {}))
.start();
}
11 changes: 5 additions & 6 deletions spawn-rs/src/spawn.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
use actor::Actor;

#[derive(Debug)]
pub struct Spawn {
system: String,
actor: Vec<dyn Actor>,
actor: Vec<Box<dyn Actor>>,
server_port: u16,
}

impl Default for Spawn {
fn default() -> Spawn {
Spawn {
system: String::from(""),
actor: Actor::default(),
actor: Vec::new(),
server_port: 8091,
system: String::from(""),
}
}
}
Expand All @@ -32,8 +31,8 @@ impl Spawn {
self
}

pub fn add_actor(&mut self, actor: dyn Actor) -> &mut Spawn {
self.actor = actor;
pub fn add_actor(&mut self, actor: Box<dyn Actor>) -> &mut Spawn {
self.actor.push(actor);
self
}

Expand Down

0 comments on commit 31fea3e

Please sign in to comment.