Open sdebionne opened 3 years ago
Looking at the code and since the nodes keep a reference to the graph
, this FR seems hardly possible.
As a straightforward workaround, have you tried to wrap graph
into std::unique_ptr
?
Thanks, that's what I end up doing, like I mention in the original comment. As a side question, what is the rational of having nodes keep a reference to a graph that can get dangling vs having the graph own the nodes (and for instance allow to visit them to get the node topology)?
I believe when flow graph was designed and introduced (in ~2010) nobody seriously thought about move semantics support that was introduced in C+11. Perhaps, it can be redesigned in such aspect but the cost of the effort and broken backward compatibility should be considered.
@anton-potapov is this issue still relevant?
When running a graph outside the main thread, it's very tempting to create the graph/nodes in the main thread and then move them to the execution thread. Unfortunately that does not work out of the box as
graph
(and probably some implementation detail such asspin_mutex
) it not movable (and neither copiable).Ideally I would like to write something like:
A workaround is to wrap the
graph
withunique_ptr
but it's not user friendly.