Skip to content

Commit a5e0c65

Browse files
slawlorutdemir
andauthored
Update ractor to 0.15.7 (#380)
* Update ractor to 0.15.7 Semver checks are clean indicating no need for a major release with these changes ``` $ cargo semver-checks -p ractor Building ractor v0.15.7 (current) Built [ 8.412s] (current) Parsing ractor v0.15.7 (current) Parsed [ 0.012s] (current) Building ractor v0.15.6 (baseline) Built [ 7.274s] (baseline) Parsing ractor v0.15.6 (baseline) Parsed [ 0.012s] (baseline) Checking ractor v0.15.6 -> v0.15.7 (minor change) Checked [ 0.035s] 140 checks: 140 pass, 37 skip Summary no semver update required Finished [ 20.651s] ractor ``` * DerivedActorRef::send_after bug fix + test coverage * Formatting --------- Co-authored-by: Utku Demir <utku@rilla.network>
1 parent b667085 commit a5e0c65

6 files changed

Lines changed: 38 additions & 5 deletions

File tree

ractor/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ractor"
3-
version = "0.15.6"
3+
version = "0.15.7"
44
authors = ["Sean Lawlor", "Evan Au", "Dillon George"]
55
description = "A actor framework for Rust"
66
documentation = "https://docs.rs/ractor"

ractor/src/actor/tests.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,18 @@ async fn derived_actor_ref() {
13451345
.send_message(u16_message)
13461346
.expect("Failed to send message to actor");
13471347

1348+
// timer
1349+
actor
1350+
.get_derived()
1351+
.send_after(Duration::from_millis(10), move || u16_message)
1352+
.await
1353+
.expect("Failed to await the join handle")
1354+
.expect("Failed to send message to actor");
1355+
1356+
sum += u16_message as u32;
1357+
1358+
// Make sure delayed send is received
1359+
crate::concurrency::sleep(Duration::from_millis(50)).await;
13481360
actor
13491361
.drain_and_wait(None)
13501362
.await

ractor/src/thread_local.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ impl ThreadLocalActorSpawner {
415415
}
416416

417417
#[cfg(all(feature = "async-std", not(target_arch = "wasm32")))]
418+
/// Create a new [ThreadLocalActorSpawner] on the current thread.
418419
pub fn new() -> Self {
419420
let (send, mut recv) = crate::concurrency::mpsc_unbounded();
420421

ractor/src/time.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,22 @@ where
232232
where
233233
F: Fn() -> TMessage + Send + 'static,
234234
{
235-
send_interval::<TMessage, F>(period, self.get_cell(), msg)
235+
// IMPORTANT: See notes on `send_interval` above for important implementation
236+
// notes
237+
let self_clone = self.clone();
238+
crate::concurrency::spawn(async move {
239+
let mut timer = crate::concurrency::interval(period);
240+
// timer tick's immediately the first time
241+
timer.tick().await;
242+
while ACTIVE_STATES.contains(&self_clone.get_status()) {
243+
timer.tick().await;
244+
// if we receive an error trying to send, the channel is closed and we should stop trying
245+
// actor died
246+
if self_clone.send_message(msg()).is_err() {
247+
break;
248+
}
249+
}
250+
})
236251
}
237252

238253
/// Alias of [send_after]
@@ -244,7 +259,12 @@ where
244259
where
245260
F: FnOnce() -> TMessage + Send + 'static,
246261
{
247-
send_after::<TMessage, F>(period, self.get_cell(), msg)
262+
let self_clone = self.clone();
263+
crate::concurrency::spawn(async move {
264+
crate::concurrency::sleep(period).await;
265+
let msg = msg();
266+
self_clone.send_message(msg)
267+
})
248268
}
249269

250270
/// Alias of [exit_after]

ractor_cluster/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ractor_cluster"
3-
version = "0.15.6"
3+
version = "0.15.7"
44
authors = ["Sean Lawlor <slawlor>"]
55
description = "Distributed cluster environment of Ractor actors"
66
documentation = "https://docs.rs/ractor"

ractor_cluster_derive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ractor_cluster_derive"
3-
version = "0.15.6"
3+
version = "0.15.7"
44
authors = ["Sean Lawlor <slawlor>"]
55
description = "Derives for ractor_cluster"
66
license = "MIT"

0 commit comments

Comments
 (0)