I need to send some "heavy" types between nodes in tbb::flow::graph (Intel TBB library), ie structure with dynamic arrays within. If I try to create an instance of such structure in one node and send a pointer on it to the other node, I get Access Violation (and this is expected, cause I try to use the data from another thread).
So only way to pass such arguments is to pass them by value using appropriate copy-constructor, isn't it? But then we will waste a lot of time for copying...
UPDATE: πάντα ῥεῖ suggests to use std::unique_ptr to pass such types through nodes. But I'm afraid I don't understand how to implement that. For example, how to use std::unique_ptr with source_node?
UPDATE 2: using std::unique_ptr<> gives C2280 'attempting to reference a deleted function' within flow_graph.h line 287.
So question is still opened.
Max,
Unfortunately the std::unique_ptr
does not have the property CopyConstructible
, which is a requirement for object messages being passed by flow::graph
.
You might try std::shared_ptr
, which does have the property. We have fixed problems with retention of objects in the buffers (which caused large objects to be retained until the graph was reset() ). If you find any problems with it, please let us know.
Regards, Chris