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

Activity manager #18797

Closed
anvilvapre opened this issue Oct 31, 2020 · 3 comments
Closed

Activity manager #18797

anvilvapre opened this issue Oct 31, 2020 · 3 comments

Comments

@anvilvapre
Copy link
Contributor

anvilvapre commented Oct 31, 2020

The Activity class currently maintains a nextActivity, childActivity and State. The first two make up the list and tree of activities. The first activity being the start and head of the list.

Each time when a (next) activity is executed the start of list is traversed to find the first child and/or sibling and execute that activity. After that the list is searched again from the start to find the next non done activity. The more activities the slower it gets to find them.

Maintaining two second lists nextDoneActivity and childDoneActivity - which contain done activities - gives the benefit that no search has to be done for the first non done activity. However this cannot be implemented as the State member is public and can be modified at any time - causing an element to be in the wrong list. Currently it seems the State is not set outside Activity though.

Many activities have 5+ child activities.

Additionally it seems a chain of activities is never reused(?). The State does not seem to be reset to again execute the same chain of activities(?). This suggests we could perhaps just drop/remove done activities.

Feature request:

  • No longer let Activity maintain a pointer to the next activity nextActivity. Only an array list of child activities.
  • Use a top level ActivityChain class that maintains a pointer to a root top level activity. That 'manages' activities.
  • Let ActivityChain only be responsible for settings the State of activities and their children. Be the main interface to users of activities.
  • Allow ActivityChain to drop/remove activities once done - or move them to a separate list - or maintain a pointer to first none done activity.
  • Let Activity maintain a pointer to its current active child. Or drop children once done.
  • Optionalyl let ActivityChain maintain a stack to all current active activities and their active child activities.
  • Optionally allow it to maintain stats on i.e. activity execution time.

Interfaces could possible stay as they are if each Activity receives a pointer to the main ActivityChain its part of.

Benefit:

  • The possibility to ignore done activities.
  • Avoid traversing a list of 4+ done activities each tick to find that last non done activity - for many actors.
  • In summary avoid calls to Activity.SkipDoneActivities

Alternative solution:

  • Make State private and allow it to change to state done only once. So that done activities can be removed.
@abcdefg30
Copy link
Member

If there is no obvious reason or need for State to be writeable publicly, we should constrain that and then go from there.

@anvilvapre
Copy link
Contributor Author

Agree.

@Shkarlatov
Copy link
Contributor

Can we close this issue? #18792 merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants