nodeeditor icon indicating copy to clipboard operation
nodeeditor copied to clipboard

TypeConverter doesn't leave room for computationally expensive conversions

Open loganmcbroom opened this issue 5 years ago • 0 comments

The ability to emit dataUpdated and propagate when data is ready allows easily passing blocking computations to another thread. The automatic type conversion between nodes doesn't allow this.

I'm fixing this by replacing TypeConverter with a class with virtual void operator()( SharedNodeData )=0 and virtual std::shared_ptrTypeConverter createNew()=0, as well as a finished() signal. The remainder of the library holds std::shared_ptrTypeConverter rather than TypeConverter, which requires a few small changes. Connection has propagateData split into setInData and propagateData. SetInData calls propagateData if no converter exists, and otherwise simply sends the input to the converter. Inheriting converters can choose to pass computation to another thread, connecting a futureWatcher finished signal e.g. to the TypeConverter finished signal, which is connected to Connection::propagateData. Finally, the createNew method is overloaded by inheritors simply as a factory for the type converter registry, since it only stores base class pointers.

I will submit these changes if it seems like a good solution, but it currently would require existing converters to be rewritten to inherit and emit, so it is maybe better to leave as is. I'm not sure how many others will have lengthy blocking conversions.

Edit: I'm not sure how to get <> to appear, so some types are incorrectly written.

loganmcbroom avatar Feb 08 '20 17:02 loganmcbroom