JBotSim icon indicating copy to clipboard operation
JBotSim copied to clipboard

Initialization callback creation

Open remikey opened this issue 6 years ago • 3 comments

We are considering adding an initialization callback (at least) on the Node class. This callback would be called before the onStart callback. Its content would be in charge of initializing the node's state, possibly avoiding the necessity of "startAndPause" trick.

Note: This issue is created partly in order to keep track of discussions.

remikey avatar Apr 29 '19 08:04 remikey

I have made an implementation proposition on feature/56-initialization-method. What's in it:

  • Topology.initialize() added It is automatically called by Topology.start() if needed.
  • InitializationListener created
    • InitializationListener.onInit() is meant to be called after the Topology's initialization
    • As for the other listeners, it has been added to the Topology
  • Node.onInit() added It is meant to be called after the Topology's initialization.
  • TopologyLifeCycle UT added to specify the basics of the topology's life cycle
  • A MainInit example has been provided

This is still modifiable.

remikey avatar Nov 12 '19 16:11 remikey

@acasteigts , following the discussion in my office:

  • Topology.initialize() does not set isStarted back to false anymore.
  • removing the new ArrayList(...) copies when notifying listeners in the hope of speeding things a bit actually raised ConcurrentModificationExceptions. I have added io.jbotsim.core.XXXListenerTests classes in test-classes (thus needing to be run manually) to tests the associated behaviors.
  • I have put in a separate commit the fact that you have a strong doubt on the fact that we can switch notifying the listeners that a Node has been added and notifying the Node that the topology has been initialized/started.

remikey avatar Jan 17 '20 09:01 remikey

  • rebased over #85 and #86
  • take latest modifications into account

remikey avatar Jan 22 '20 10:01 remikey