Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions ractor/benches/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
#[macro_use]
extern crate criterion;

use criterion::{BatchSize, Criterion};
use criterion::BatchSize;
use criterion::Criterion;
use ractor::Actor;
use ractor::ActorProcessingErr;
use ractor::ActorRef;
#[cfg(feature = "cluster")]
use ractor::Message;
use ractor::{Actor, ActorProcessingErr, ActorRef};

struct BenchActor;

Expand Down
7 changes: 5 additions & 2 deletions ractor/benches/async_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
#[macro_use]
extern crate criterion;

use criterion::{BatchSize, Criterion};
use criterion::BatchSize;
use criterion::Criterion;
use ractor::Actor;
use ractor::ActorProcessingErr;
use ractor::ActorRef;
#[cfg(feature = "cluster")]
use ractor::Message;
use ractor::{Actor, ActorProcessingErr, ActorRef};

#[allow(clippy::async_yields_async)]
fn big_stack_futures(c: &mut Criterion) {
Expand Down
5 changes: 4 additions & 1 deletion ractor/examples/a_whole_lotta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@

extern crate ractor;

use ractor::{Actor, ActorProcessingErr, ActorRef};
use ractor::Actor;
use ractor::ActorProcessingErr;
use ractor::ActorRef;

struct Counter;

Expand All @@ -41,6 +43,7 @@ fn init_logging() {

use std::io::stderr;
use std::io::IsTerminal;

use tracing_glog::Glog;
use tracing_glog::GlogFields;
use tracing_subscriber::filter::EnvFilter;
Expand Down
6 changes: 5 additions & 1 deletion ractor/examples/a_whole_lotta_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@

extern crate ractor;

use ractor::{concurrency::Duration, Actor, ActorProcessingErr, ActorRef};
use ractor::concurrency::Duration;
use ractor::Actor;
use ractor::ActorProcessingErr;
use ractor::ActorRef;

struct Counter;

Expand Down Expand Up @@ -52,6 +55,7 @@ fn init_logging() {

use std::io::stderr;
use std::io::IsTerminal;

use tracing_glog::Glog;
use tracing_glog::GlogFields;
use tracing_subscriber::filter::EnvFilter;
Expand Down
7 changes: 6 additions & 1 deletion ractor/examples/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

extern crate ractor;

use ractor::{call_t, Actor, ActorProcessingErr, ActorRef, RpcReplyPort};
use ractor::call_t;
use ractor::Actor;
use ractor::ActorProcessingErr;
use ractor::ActorRef;
use ractor::RpcReplyPort;

struct Counter;

Expand Down Expand Up @@ -79,6 +83,7 @@ fn init_logging() {

use std::io::stderr;
use std::io::IsTerminal;

use tracing_glog::Glog;
use tracing_glog::GlogFields;
use tracing_subscriber::filter::EnvFilter;
Expand Down
10 changes: 8 additions & 2 deletions ractor/examples/monte_carlo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@

use std::collections::HashMap;

use ractor::{cast, Actor, ActorId, ActorProcessingErr, ActorRef};
use rand::{thread_rng, Rng};
use ractor::cast;
use ractor::Actor;
use ractor::ActorId;
use ractor::ActorProcessingErr;
use ractor::ActorRef;
use rand::thread_rng;
use rand::Rng;

// ================== Player Actor ================== //

Expand Down Expand Up @@ -208,6 +213,7 @@ fn init_logging() {

use std::io::stderr;
use std::io::IsTerminal;

use tracing_glog::Glog;
use tracing_glog::GlogFields;
use tracing_subscriber::filter::EnvFilter;
Expand Down
9 changes: 7 additions & 2 deletions ractor/examples/output_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ extern crate ractor;

use std::sync::Arc;

use ractor::{Actor, ActorProcessingErr, ActorRef, OutputPort};
use tokio::time::{timeout, Duration};
use ractor::Actor;
use ractor::ActorProcessingErr;
use ractor::ActorRef;
use ractor::OutputPort;
use tokio::time::timeout;
use tokio::time::Duration;

enum PublisherMessage {
Publish(String),
Expand Down Expand Up @@ -107,6 +111,7 @@ fn init_logging() {

use std::io::stderr;
use std::io::IsTerminal;

use tracing_glog::Glog;
use tracing_glog::GlogFields;
use tracing_subscriber::filter::EnvFilter;
Expand Down
17 changes: 13 additions & 4 deletions ractor/examples/philosophers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,18 @@

#![allow(clippy::incompatible_msrv)]

use std::collections::{HashMap, VecDeque};

use ractor::{cast, Actor, ActorId, ActorName, ActorProcessingErr, ActorRef, RpcReplyPort};
use tokio::time::{Duration, Instant};
use std::collections::HashMap;
use std::collections::VecDeque;

use ractor::cast;
use ractor::Actor;
use ractor::ActorId;
use ractor::ActorName;
use ractor::ActorProcessingErr;
use ractor::ActorRef;
use ractor::RpcReplyPort;
use tokio::time::Duration;
use tokio::time::Instant;

// ============================ Fork Actor ============================ //

Expand Down Expand Up @@ -465,6 +473,7 @@ fn init_logging() {

use std::io::stderr;
use std::io::IsTerminal;

use tracing_glog::Glog;
use tracing_glog::GlogFields;
use tracing_subscriber::filter::EnvFilter;
Expand Down
6 changes: 5 additions & 1 deletion ractor/examples/ping_pong.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

extern crate ractor;

use ractor::{cast, Actor, ActorProcessingErr, ActorRef};
use ractor::cast;
use ractor::Actor;
use ractor::ActorProcessingErr;
use ractor::ActorRef;

pub struct PingPong;

Expand Down Expand Up @@ -85,6 +88,7 @@ fn init_logging() {

use std::io::stderr;
use std::io::IsTerminal;

use tracing_glog::Glog;
use tracing_glog::GlogFields;
use tracing_subscriber::filter::EnvFilter;
Expand Down
8 changes: 6 additions & 2 deletions ractor/examples/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@

#![allow(clippy::incompatible_msrv)]

use ractor::{Actor, ActorProcessingErr, ActorRef, RpcReplyPort, SupervisionEvent};

use ractor::Actor;
use ractor::ActorProcessingErr;
use ractor::ActorRef;
use ractor::RpcReplyPort;
use ractor::SupervisionEvent;
use tokio::time::Duration;

// ============================== Main ============================== //
Expand All @@ -24,6 +27,7 @@ fn init_logging() {

use std::io::stderr;
use std::io::IsTerminal;

use tracing_glog::Glog;
use tracing_glog::GlogFields;
use tracing_subscriber::filter::EnvFilter;
Expand Down
4 changes: 0 additions & 4 deletions ractor/rustfmt.toml

This file was deleted.

14 changes: 11 additions & 3 deletions ractor/src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,19 @@ mod supervision_tests;
#[cfg(test)]
mod tests;

use crate::errors::{ActorErr, ActorProcessingErr, MessagingErr, SpawnErr};
use crate::{ActorName, Message, State};
use actor_cell::{ActorCell, ActorPortSet, ActorStatus};
use actor_cell::ActorCell;
use actor_cell::ActorPortSet;
use actor_cell::ActorStatus;
use actor_ref::ActorRef;

use crate::errors::ActorErr;
use crate::errors::ActorProcessingErr;
use crate::errors::MessagingErr;
use crate::errors::SpawnErr;
use crate::ActorName;
use crate::Message;
use crate::State;

pub(crate) fn get_panic_string(e: Box<dyn std::any::Any + Send>) -> ActorProcessingErr {
match e.downcast::<String>() {
Ok(v) => From::from(*v),
Expand Down
17 changes: 12 additions & 5 deletions ractor/src/actor/actor_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@ use std::sync::Arc;
use futures::FutureExt;

use super::actor_properties::MuxedMessage;
use super::messages::{Signal, StopMessage};
use super::messages::Signal;
use super::messages::StopMessage;
use super::SupervisionEvent;
use crate::actor::actor_properties::ActorProperties;
use crate::concurrency::{JoinHandle, MpscUnboundedReceiver as InputPortReceiver, OneshotReceiver};
use crate::concurrency::JoinHandle;
use crate::concurrency::MpscUnboundedReceiver as InputPortReceiver;
use crate::concurrency::OneshotReceiver;
use crate::errors::MessagingErr;
#[cfg(feature = "cluster")]
use crate::message::SerializedMessage;
use crate::{Actor, ActorName, SpawnErr};
use crate::{ActorId, Message};
use crate::{ActorRef, RactorErr};
use crate::Actor;
use crate::ActorId;
use crate::ActorName;
use crate::ActorRef;
use crate::Message;
use crate::RactorErr;
use crate::SpawnErr;

/// [ActorStatus] represents the status of an actor's lifecycle
#[derive(Debug, Clone, Eq, PartialEq, Copy, PartialOrd, Ord)]
Expand Down
3 changes: 2 additions & 1 deletion ractor/src/actor/actor_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
//! ActorIds are generally helpful in logging and pattern matching, but not directly
//! used in addressing outside of `ractor_cluster` network-based call internals.

use std::{fmt::Display, sync::atomic::AtomicU64};
use std::fmt::Display;
use std::sync::atomic::AtomicU64;

/// An actor's globally unique identifier
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
Expand Down
25 changes: 17 additions & 8 deletions ractor/src/actor/actor_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,29 @@
// This source code is licensed under both the MIT license found in the
// LICENSE-MIT file in the root directory of this source tree.

use std::sync::atomic::{AtomicU8, Ordering};
use std::sync::{Arc, Mutex};
use std::sync::atomic::AtomicU8;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::sync::Mutex;

use crate::actor::messages::StopMessage;
use crate::actor::supervision::SupervisionTree;
use crate::concurrency::{
MpscUnboundedReceiver as InputPortReceiver, MpscUnboundedSender as InputPort, OneshotReceiver,
OneshotSender as OneshotInputPort,
};
use crate::concurrency as mpsc;
use crate::concurrency::MpscUnboundedReceiver as InputPortReceiver;
use crate::concurrency::MpscUnboundedSender as InputPort;
use crate::concurrency::OneshotReceiver;
use crate::concurrency::OneshotSender as OneshotInputPort;
use crate::message::BoxedMessage;
#[cfg(feature = "cluster")]
use crate::message::SerializedMessage;
use crate::{concurrency as mpsc, Message};
use crate::{Actor, ActorId, ActorName, ActorStatus, MessagingErr, Signal, SupervisionEvent};
use crate::Actor;
use crate::ActorId;
use crate::ActorName;
use crate::ActorStatus;
use crate::Message;
use crate::MessagingErr;
use crate::Signal;
use crate::SupervisionEvent;

/// A muxed-message wrapper which allows the message port to receive either a message or a drain
/// request which is a point-in-time marker that the actor's input channel should be drained
Expand Down
6 changes: 4 additions & 2 deletions ractor/src/actor/actor_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

use std::marker::PhantomData;

use crate::{ActorName, Message, MessagingErr, SupervisionEvent};

use super::ActorCell;
use crate::ActorName;
use crate::Message;
use crate::MessagingErr;
use crate::SupervisionEvent;

/// An [ActorRef] is a strongly-typed wrapper over an [ActorCell]
/// to provide some syntactic wrapping on the requirement to pass
Expand Down
6 changes: 5 additions & 1 deletion ractor/src/actor/derived_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
//! to its accepted type using [From]. It represents a subset of the messages supported
//! by the original actor.

use crate::{ActorCell, ActorRef, Message, MessagingErr};
use std::sync::Arc;

use crate::ActorCell;
use crate::ActorRef;
use crate::Message;
use crate::MessagingErr;

/// [DerivedActorRef] wraps an [ActorCell] to send messages that can be converted
/// into its accepted type using [From]. [DerivedActorRef] allows to create isolation
/// between actors by hiding the actual message type.
Expand Down
3 changes: 2 additions & 1 deletion ractor/src/actor/supervision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
use std::collections::HashMap;
use std::sync::Mutex;

use super::{actor_cell::ActorCell, messages::SupervisionEvent};
use super::actor_cell::ActorCell;
use super::messages::SupervisionEvent;
use crate::ActorId;

/// A supervision tree
Expand Down
22 changes: 14 additions & 8 deletions ractor/src/actor/supervision_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@

//! Supervisor tests

use std::sync::{
atomic::{AtomicU64, AtomicU8, Ordering},
Arc,
};

use crate::{concurrency::Duration, message::BoxedDowncastErr, periodic_check, ActorProcessingErr};

use crate::{Actor, ActorCell, ActorRef, ActorStatus, SupervisionEvent};
use std::sync::atomic::AtomicU64;
use std::sync::atomic::AtomicU8;
use std::sync::atomic::Ordering;
use std::sync::Arc;

use crate::concurrency::Duration;
use crate::message::BoxedDowncastErr;
use crate::periodic_check;
use crate::Actor;
use crate::ActorCell;
use crate::ActorProcessingErr;
use crate::ActorRef;
use crate::ActorStatus;
use crate::SupervisionEvent;

#[crate::concurrency::test]
#[cfg_attr(
Expand Down
Loading
Loading