I have found a small design problem with the current event system code and Jorrit recommended I ask the list for optionions on how to fix it. So here it goes.
THE PROBLEM: The csevSystemOpen (and csevSystemClose) events need to be delivered in the same order that their plugins were loaded (reverse order for csevSystemClose?). With the old system that was easy because event handlers would just be put on the end of a list at subscription time and would get handled in that order. With the new event system this is no longer the case and event handlers are stored in a partial ordering graph. The plugin loading ordering dependencies are currently stored in the .csplugin files while the event handler ordering constraints are specified as part of member functions in the event handlers. These two pieces of information have not been kept in sync. The current partial ordering graph code just happens to order them in the correct order, but as simple a change as the patch below [1] will cause the event handlers to be in the wrong order. (I was writing some optimizations for the partial order graph when I found this problem. With the current code, patch [1] will result in a distorted view frustum due to engine and render3d having their events in the wrong order.) Since we have not been able to keep the plugin loading and the event system orderings in sync, it would be nice if we could derive the event system ordering from the plugin loading order and avoid having to specify the same information twice. Anyone have any ideas for a solution? OBSTACLES: Two obstacles that you should be aware of are that plugin dependencies may be specified as a wild card (e.g. "crystal.graphics3d." <- note the dot) that loads a plugin (e.g. "crystal.graphics3d.opengl") with a more specific name than the event handler name that the plugin uses (e.g. "crystal.graphics3d"). The other is that the event handler may be using a (false) embedded class such as csGLGraphics3D::scfiEventHandler so it is not possible to just ask for the event handler from the plugin and form their get it's event handler name. IDEAS: Now I have a few ideas for working around this but other solutions are welcome: (1) make event handler names be hierachrical (i.e. crystal.render3d as a pre constraint means that crystal.render3d.opengl is also a pre-constraint) (2) whenever a wildcard plugin name is found (e.g. crystal.render3d.) assume that it is a generic event name (e.g. crystal.render3d); (3) actually put the event handler ordering constraints in csplugin along side of and seperate from the plugin dependancy constraints; (4) do special magic for csevSystemOpen that makes the partial order behave like a FIFO for that particular event (may be important if an event handler, a, requests plugins that have constraints requiring it's event handler, b, to occur before an event handler, c, that has already fired, with the current system, that new event handler, b, will receive the csevSystemOpen message if c has already fired (the user's fault but it might be hard to debug)) On IRC Jorrit noted that "(1) has the disadvantage that it ties a meaning to a name and that it should be possible to make a renderer event handler that is for example called 'cel.specialcelrenderer.eventhandler'. And if other applications register their event handlers that implement some common interface then they might want to use 'planeshift.render3d.' .... It might be that the solutions are actually worse then the original problem (duplication of information)." Michael D. Adams [1] This patch simply makes the partial order solution produces results in a different though equally correct order. Index: include/csutil/partialorder.h =================================================================== --- include/csutil/partialorder.h (revision 25228) +++ include/csutil/partialorder.h (working copy) @@ -288,7 +288,8 @@ do { done = true; - for (size_t iter=0 ; iter<Nodes.Length() ; iter++) + //for (size_t iter=0 ; iter<Nodes.Length() ; iter++) + for (size_t iter=Nodes.Length(); iter-- > 0; ) { if (Nodes[iter].output == false) { @@ -391,7 +392,8 @@ */ const T GetEnabled(T fail) { - for (size_t i=0 ; i<Nodes.Length() ; i++) + //for (size_t i=0 ; i<Nodes.Length() ; i++) + for (size_t i=Nodes.Length() ; i-- > 0; ) { if (InternalIsEnabled(i)) return Nodes[i].self; ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Crystal-main mailing list Crystal-main@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/crystal-main Unsubscribe: mailto:[EMAIL PROTECTED]