Skip to content
Open
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
6 changes: 3 additions & 3 deletions concurrency/src/tasks/gen_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ pub enum InitResult<G: GenServer> {
}

pub trait GenServer: Send + Sized {
type CallMsg: Clone + Send + Sized + Sync;
type CastMsg: Clone + Send + Sized + Sync;
type OutMsg: Send + Sized;
type CallMsg: Send;
type CastMsg: Send;
type OutMsg: Send;
type Error: Debug + Send;

fn start(self) -> GenServerHandle<Self> {
Expand Down
9 changes: 6 additions & 3 deletions concurrency/src/tasks/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ where

let async_block = pin!(async {
rt::sleep(period).await;
let _ = handle.cast(message.clone()).await;
let _ = handle.cast(message).await;
});
let _ = select(cancel_conditions, async_block).await;
});
Expand All @@ -50,6 +50,7 @@ pub fn send_interval<T>(
) -> TimerHandle
where
T: GenServer + 'static,
T::CastMsg: Clone,
{
let cancellation_token = CancellationToken::new();
let cloned_token = cancellation_token.clone();
Expand All @@ -61,9 +62,11 @@ where
let genserver_cancel_fut = pin!(gen_server_cancellation_token.cancelled());
let cancel_conditions = select(cancel_token_fut, genserver_cancel_fut);

let async_block = pin!(async {
let message_clone = message.clone();
let handle_reference = &mut handle;
let async_block = pin!(async move {
rt::sleep(period).await;
let _ = handle.cast(message.clone()).await;
let _ = handle_reference.cast(message_clone).await;
});
let result = select(cancel_conditions, async_block).await;
match result {
Expand Down