Extension Threading

Oh boy, what a load of code.

So, in talking with Marcus we were talking about how to handle threading. His
approach that he’s working on is to make a different type of extension which
runs in it’s own thread. I’m not really solid on his architecture for this
so i’ll leave it up to him to explain.

The progress I made tonight was to make it so that the extension has a
QUndoCommand and the QUndoCommand is responsible for making it’s own thread.
As of now this gets complicated because GhemicalExtension now has a
GhemicalCommand, and GhemicalCommand relies on GhemicalThread. This is not
too bad but it looks messy.

The reason I think this is good is because for one, Avogadro doesn’t have to
worry about the threading experience. In most cases that Geoff and I have
talked, these threads will be for external applications that will be run
along side of Avogadro. But what is really important to me is the Undo/Redo
stack. The problem we have is that we must be very concerned with order of
operations. If there is a long running task that is going to put data back
into Avogadro, then it’s important nothing happens to the Molecule between
passing it off and then getting it back. Now, if the script we’re running is
purely informational, then it’s no biggy and there will be no undo/redo
command thus a thread can go off and just return us a dialog or some text.

Also, QUndoCommand is not a subclass of QObject, so GhemicalCommand could be
QUndoCommand and a QThread. cmake gave me an error when generating the .moc
file but this is wrong as far as the QT documentation says. this could
help alleviate some of the stress, but i don’t think this is going to
continue to be an easy problem. The nice thing right now is it doesn’t break
any of our current interfaces and the current architecture. We should
definatly discuss if we need to just leave the threading to the extensions or
actually have Avogadro manage some of the threads. At this point I don’t see
any problems with leaving it to the Extensions. It’s easier on us, but
probably harder on extension developers. I’m not sure if we can make it
easier on developers.


Donald