From 77f62a22fd9f1fed2875c466f52f3f7ece58bd09 Mon Sep 17 00:00:00 2001 From: ElFantasma Date: Wed, 25 Jun 2025 11:08:31 -0300 Subject: [PATCH] Revert "Removed the requirement of implementing Clone on CallMsg and CastMsg" --- concurrency/src/tasks/gen_server.rs | 4 ++-- concurrency/src/tasks/time.rs | 3 +-- concurrency/src/threads/gen_server.rs | 4 ++-- concurrency/src/threads/time.rs | 1 - 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/concurrency/src/tasks/gen_server.rs b/concurrency/src/tasks/gen_server.rs index 7c6d01d..a72a52a 100644 --- a/concurrency/src/tasks/gen_server.rs +++ b/concurrency/src/tasks/gen_server.rs @@ -105,8 +105,8 @@ pub trait GenServer where Self: Send + Sized, { - type CallMsg: Send + Sized + Sync; - type CastMsg: Send + Sized + Sync; + type CallMsg: Clone + Send + Sized + Sync; + type CastMsg: Clone + Send + Sized + Sync; type OutMsg: Send + Sized; type State: Clone + Send; type Error: Debug + Send; diff --git a/concurrency/src/tasks/time.rs b/concurrency/src/tasks/time.rs index 691bf3f..f26118b 100644 --- a/concurrency/src/tasks/time.rs +++ b/concurrency/src/tasks/time.rs @@ -27,7 +27,7 @@ where Box::pin(cloned_token.cancelled()), Box::pin(async { rt::sleep(period).await; - let _ = handle.cast(message).await; + let _ = handle.cast(message.clone()).await; }), ) .await; @@ -46,7 +46,6 @@ pub fn send_interval( ) -> TimerHandle where T: GenServer + 'static, - T::CastMsg: Clone, { let cancellation_token = CancellationToken::new(); let cloned_token = cancellation_token.clone(); diff --git a/concurrency/src/threads/gen_server.rs b/concurrency/src/threads/gen_server.rs index 912067b..9d58754 100644 --- a/concurrency/src/threads/gen_server.rs +++ b/concurrency/src/threads/gen_server.rs @@ -83,8 +83,8 @@ pub trait GenServer where Self: Send + Sized, { - type CallMsg: Send + Sized; - type CastMsg: Send + Sized; + type CallMsg: Clone + Send + Sized; + type CastMsg: Clone + Send + Sized; type OutMsg: Send + Sized; type State: Clone + Send; type Error: Debug; diff --git a/concurrency/src/threads/time.rs b/concurrency/src/threads/time.rs index 2819bbe..3d47c05 100644 --- a/concurrency/src/threads/time.rs +++ b/concurrency/src/threads/time.rs @@ -41,7 +41,6 @@ pub fn send_interval( ) -> TimerHandle where T: GenServer + 'static, - T::CastMsg: Clone, { let cancellation_token = CancellationToken::new(); let mut cloned_token = cancellation_token.clone();