Skip to content

Commit

Permalink
Make LocalActor !Send && !Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
mbernat committed May 22, 2024
1 parent 0fe4eb6 commit c3a17e6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,7 @@ impl<M: Into<N>, N> SenderTrait<M> for Arc<dyn SenderTrait<N>> {
#[cfg(test)]
mod tests {
use std::{
rc::Rc,
sync::atomic::{AtomicU32, Ordering},
time::Duration,
};
Expand Down Expand Up @@ -1100,7 +1101,9 @@ mod tests {
#[test]
fn send_constraints() {
#[derive(Default)]
struct LocalActor;
struct LocalActor {
_ensure_not_send_not_sync: Rc<()>,
}
impl Actor for LocalActor {
type Context = Context<Self::Message>;
type Error = ();
Expand All @@ -1123,10 +1126,10 @@ mod tests {
let mut system = System::new("main");

// Allowable, as the struct will be created on the new thread.
let _ = system.prepare_fn(|| LocalActor).with_default_capacity().spawn().unwrap();
let _ = system.prepare_fn(LocalActor::default).with_default_capacity().spawn().unwrap();

// Allowable, as the struct will be run on the current thread.
system.prepare(LocalActor).with_default_capacity().run_and_block().unwrap();
system.prepare(LocalActor::default()).with_default_capacity().run_and_block().unwrap();

system.shutdown().unwrap();
}
Expand Down

0 comments on commit c3a17e6

Please sign in to comment.