-
Notifications
You must be signed in to change notification settings - Fork 68
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
Experimental Router #252
Comments
Overall I like the idea of this router. |
I think if multiple receivers are attached to the same key it should do as you would expect and send a copy to both (as it does currently). I like the idea of moving to a |
@FelixPetriconi Mods are done. I am not sure about the use of |
@aaronalbers I would apply a stable_sort on all receivers when the user has called set_ready. Then all values of the same category come after each other and no rearranging is necessary. As well then you run into synchronisation issues when the router is part of a whole graph where the router could be triggered from multiple threads at the same time. |
@FelixPetriconi I was thinking about your suggestion but there is a problem. Since there is only ever 1 receiver per key and the categories of receivers are dependent on both the key and the value we will have to resort to a full linear scan for each route. That is if we want to keep the ability to "multicast" to a set of receivers depending on the input. Even if the Perhaps two versions (or modes) of the router would be helpful. One that doesn't multicast with a deterministic predicate and the other that is more flexible. The advantage of the first would be increased performance. |
@FelixPetriconi I think I found a way that is the best of both worlds. The provided function takes the value to route and returns a |
@aaronalbers I am not sure, if std::set<> is the correct container for such a task, because it is as a node based container much more expensive than a std::vector<>. I have to go into deeper into this, but I am a bit short of time at the moment, sorry. |
@FelixPetriconi The code will work with a |
@aaronalbers I understand now, why you are returning a container from the route function. Doing it such makes the code nice and uncomplicated. std::set has its advantages of guaranteeing uniqueness of the elements, but from the point of cache friendliness it is problematic, because each node is somewhere else in memory. So a vector would be better here. With a simple append_unique function one could ensure, that each key just appears ones. |
@FelixPetriconi I have updated the example with the ability to return any container type including There are two options for the
As always the container returned must be sorted by Note: |
@aaronalbers I think the router would be a valuable extension to the library. |
@FelixPetriconi Option 2 allows you to use Given At least with option 2 you can maintain the same flexibility of option 1 without a container that utilizes an allocator. Should this live in Edit: |
I did not make my point clear enough. Returning a vector is fine for your current dynamic setup. In case that one goes for a compile time variant of the router, then one could use a array<> to hold the values. In this case, I would pass to the routing function a pair of iterators, that spread the complete array<> and then it get filled from bottom to the last key and then this returns the iterator pointing beyond the last used element. So the calling function holds an array<key, N>, where N is equal to the number of routes. It should go into router.hpp |
@FelixPetriconi Ah. I think I understand now. I am curious to see what that would look like in practice. The PR is up #256 |
@aaronalbers thanks for the PR; we'll take a look. |
I built out a router for channels that allows you to conditionally send data down different paths. An example use case might be routing web requests based on the url of the request. If this proves to be useful perhaps something like this could be added to the library. The following example routes based on the contents of a string.
The text was updated successfully, but these errors were encountered: