Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delayed/recurring messages are not delivered to busy actors #72

Closed
strohel opened this issue Feb 24, 2023 · 0 comments · Fixed by #73
Closed

Delayed/recurring messages are not delivered to busy actors #72

strohel opened this issue Feb 24, 2023 · 0 comments · Fixed by #73
Assignees
Labels
bug Something isn't working

Comments

@strohel
Copy link
Member

strohel commented Feb 24, 2023

When a Timed<> actor does something like

fn handle(&mut self, context, message) {
    sleep(some time);
    context.myself.send_now(some message);
}

Then delayed or recurring messages are never delivered to it (no matter what priority they have), because Timed wrapper only processes them in deadline_exceeded(), which is never called (because the queue in never empty in actors event loop handling).

@strohel strohel added the bug Something isn't working label Feb 24, 2023
strohel added a commit that referenced this issue Feb 24, 2023
This fixes the recurring_messages_for_busy_actors test, and should fix #72.
@strohel strohel self-assigned this Feb 27, 2023
strohel added a commit that referenced this issue Feb 28, 2023
* Add test showcasing delayed messages not delivered to busy actors

This test currently fails with
```
---- timed::tests::it_works stdout ----
thread 'timed::tests::it_works' panicked at 'assertion failed: `(left == right)`
  left: `[1, 3, 3]`,
 right: `[1, 2, 3, 2, 3]`', src/timed.rs:318:9
```

I.e. messages of type 2 (delayed) are never delivered.

* Process delayed/recurring messages also for busy actors

This fixes the recurring_messages_for_busy_actors test, and should fix #72.

* Shuffle queue handling order, add/improve code comments

The order does not matter much (it for example does not change the order or received messages in the test), but I've found this way more logical.

* Fix typo

* Better commend wording
strohel added a commit that referenced this issue Jan 12, 2024
…when due

Also rename `fire_at` to `enqueue_at` to be explicit about the fact.

This is a trade-off that prevents 2 sorts of bad behavior:
- actors with send-sending messages never handling any delayed/recurring messages (#72)
- actors with recurring messages that are slower to handle than their interval eventually not processing any outside messages (#79)

See the tweaked tests for the change of behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant