Comments (5)
Hi!
It's not an easy question. Let me take some time to think about it.
from sobjectizer.
It seems that this case requires support of messages with different priorities. In that case you can have msg_do_something_heavy
with low priority and msg_shutdown
with high priority. It allows to switch an agent in a different state when msg_shutdown
arrives (message msg_do_something_heavy
will just be ignored in that state):
class SlowAgent : public so_5::agent_t
{
state_t st_normal{this};
state_t st_shut_down{this};
...
public:
void so_define_agent() override
{
this >>= st_normal;
st_normal
.event([](mhood_t<msg_do_something_heavy> cmd) {
... // Some time-consuming processing.
})
.event([this](mhood_t<msg_shutdown>) {
this >> st_shut_down; // Or call so_deactivate_agent().
});
// No subscription for st_shut_down.
}
...
};
In that case, you send a msg_shutdown
message before shutting your agent. That message will be delivered before any other messages that are already in the event queue (like msg_do_something_heavy
). The agent will be switched to a state in that all other messages will just be ignored.
But SO-5.6/5.7 doesn't support message priorities.
There is an example how a dispatcher with priorities can be implemented: https://github.com/Stiffstream/so5_custom_queue_disps_demo
And the description of that example in Russian: https://habr.com/ru/post/531566/ (Hope a service like Google Translate or DeepL can help here).
from sobjectizer.
Thanks @eao197 for your response. Message priorities would be the perfect fit. However, at the moment I don't want to introduce too much "custom code" around the framework.
Actually, I have redesigned the data flow of this particular agent in terms of a message chain and solved this problem by closing it with drop_content
. It's not as slick as with message priorities but it's an acceptable trade-off at the moment.
Any future plans for making them a standard feature?
from sobjectizer.
Any future plans for making them a standard feature?
Because it's another time when message priorities are discussed this feature has to be added to SObjectizer in some form (maybe in the form of another dispatcher). But it's hard to predict when it could be done in the current situation. I hope github won't be closed for my country.
from sobjectizer.
Sure @eao197 , the current situation is critical and definitely much more important than any other things right now. Definitely impossible to make any predictions.
from sobjectizer.
Related Issues (20)
- Asynchrony of register_coop HOT 4
- Documentation for message_holder_t has to be extended HOT 1
- A usage example for agent_t::limit_then_redirect method in API Reference HOT 1
- [Design] Your opinion on expressing agent intent HOT 2
- Deprecation of coop_t::deregister and coop_t::deregister_normally methods HOT 1
- [idea] An emergency stop of SOEnv on an exception in noexcept context HOT 1
- `so_evt_finish` not called until `so_evt_start` is running? HOT 2
- Should agent_t::so_drop_subscription* methods be marked as noexcept? HOT 1
- Should delivery filters be checked for noexcept-ness?
- bind_and_transform HOT 10
- so_5::details::make_message_instance_impl metafunction doesn't set message mutability flag properly HOT 1
- limit_then_transform for mutable messages HOT 1
- Allow `const auto &` as an argument for delivery filter in single/multi_sink_binding HOT 1
- Should there be agent_t::so_disp_binder() and agent_t::so_coop_default_disp_binder() methods? HOT 2
- [idea] Make so5extra's revocable timers the default implementation for timers in SObjectizer
- Another constructor for wrapped_env_t that waits completion of init-function HOT 1
- Use of message limits and state_t::time_limit
- Optional name for an agent? HOT 2
- New method `as_string_view` for so_5::stats::prefix_t and so_5::stats::suffix_t HOT 1
- SO_5_TYPE shouldn't be used for so_5::stats::messages::quantity
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sobjectizer.