The PR proposes a new abstract method in the Agent class, the update() method. This method is called at every iteration of the main loop of the agent (that is, the one in the method run_main_loop()). The purpose of the update() method is to handle generic operations to update the state of the agent.
Notice how it differs from the act() method, that handles the outputs of the agent, and the react() method, that handles the inputs of the agent.
Moreover, it's worth noticing that, at the moment, this is just a logical separation of operations, rather than an increase in expressiveness. There's no practical difference between the react and the update method.
Fixes
This PR is somehow related to #295. That's because some operations that we used to accomplish by allocating threads now can be completed inside this method.
Among other changes, the PR brings also small fixes to the source code.
Types of changes
What types of changes does your code introduce to agents-tac?
Put an x in the boxes that apply
[ ] Bugfix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[X] Breaking change (fix or feature that would cause existing functionality to not work as expected)
[X] I am making a pull request against the develop branch (left side). Also you should start your branch off our develop.
[ ] Lint and unit tests pass locally with my changes
[ ] I have added tests that prove my fix is effective or that my feature works
[ ] I have added necessary documentation (if appropriate)
[ ] Any dependent changes have been merged and published in downstream modules
Further comments
It could be possible to generalize this method by including a task_queue that consumes small tasks, so instead of requiring the programmer to implement the update() method, he could just enqueue some tasks in the task_queue, delegating its execution to the framework. That implies the need for defining the right abstractions, error handling etc.
Another remark is that, while before this change the cleanup job of the TransactionManager run every _cleanup_locked_transactions_task_timeout seconds, now it runs at the same rate of the main loop. That might not be the desired behaviour. The replication of the same behaviour requires some efforts to the developer. So it's worth thinking about a way to make his life easier.
Proposed changes
The PR proposes a new abstract method in the
Agent
class, theupdate()
method. This method is called at every iteration of the main loop of the agent (that is, the one in the methodrun_main_loop()
). The purpose of theupdate()
method is to handle generic operations to update the state of the agent.Notice how it differs from the
act()
method, that handles the outputs of the agent, and thereact()
method, that handles the inputs of the agent. Moreover, it's worth noticing that, at the moment, this is just a logical separation of operations, rather than an increase in expressiveness. There's no practical difference between thereact
and theupdate
method.Fixes
This PR is somehow related to #295. That's because some operations that we used to accomplish by allocating threads now can be completed inside this method.
Among other changes, the PR brings also small fixes to the source code.
Types of changes
What types of changes does your code introduce to agents-tac? Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply.develop
branch (left side). Also you should start your branch off ourdevelop
.Further comments
task_queue
that consumes small tasks, so instead of requiring the programmer to implement theupdate()
method, he could just enqueue some tasks in thetask_queue
, delegating its execution to the framework. That implies the need for defining the right abstractions, error handling etc.TransactionManager
run every_cleanup_locked_transactions_task_timeout
seconds, now it runs at the same rate of the main loop. That might not be the desired behaviour. The replication of the same behaviour requires some efforts to the developer. So it's worth thinking about a way to make his life easier.