13
0

Use a GraphNode base-class for processing

The process-graph trigger_queue only needs to call
::prep() and ::run() without knowing any further details.

This is in preparation for using the graph-threads for rt-tasks
This commit is contained in:
Robin Gareus 2022-06-04 15:22:05 +02:00
parent c1a1d12354
commit 7219791d22
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 18 additions and 9 deletions

View File

@ -41,6 +41,7 @@
namespace ARDOUR
{
class ProcessNode;
class GraphNode;
class Graph;
@ -82,7 +83,7 @@ public:
uint32_t n_threads () const;
/* called by GraphNode */
void trigger (GraphNode* n);
void trigger (ProcessNode* n);
void reached_terminal_node ();
/* called by virtual GraphNode::process() */
@ -101,8 +102,8 @@ private:
void helper_thread ();
PBD::MPMCQueue<GraphNode*> _trigger_queue; ///< nodes that can be processed
GATOMIC_QUAL guint _trigger_queue_size; ///< number of entries in trigger-queue
PBD::MPMCQueue<ProcessNode*> _trigger_queue; ///< nodes that can be processed
GATOMIC_QUAL guint _trigger_queue_size; ///< number of entries in trigger-queue
/** Start worker threads */
PBD::Semaphore _execution_sem;

View File

@ -42,6 +42,14 @@ typedef boost::shared_ptr<GraphNode> node_ptr_t;
typedef std::set<node_ptr_t> node_set_t;
typedef std::list<node_ptr_t> node_list_t;
class LIBARDOUR_API ProcessNode
{
public:
virtual ~ProcessNode() {}
virtual void prep (GraphChain const*) = 0;
virtual void run (GraphChain const*) = 0;
};
class LIBARDOUR_API GraphActivision
{
public:
@ -64,15 +72,14 @@ protected:
};
/** A node on our processing graph, ie a Route */
class LIBARDOUR_API GraphNode : public GraphActivision
class LIBARDOUR_API GraphNode : public ProcessNode, public GraphActivision
{
public:
GraphNode (boost::shared_ptr<Graph> Graph);
/* API used by Graph */
void prep (GraphChain const*);
void trigger ();
void run (GraphChain const* chain);
void run (GraphChain const*);
/* API used to sort Nodes and create GraphChain */
virtual std::string graph_node_name () const = 0;
@ -80,6 +87,7 @@ public:
virtual bool direct_feeds_according_to_reality (boost::shared_ptr<GraphNode>, bool* via_send_only = 0) = 0;
protected:
void trigger ();
virtual void process () = 0;
boost::shared_ptr<Graph> _graph;

View File

@ -226,7 +226,7 @@ Graph::prep ()
}
void
Graph::trigger (GraphNode* n)
Graph::trigger (ProcessNode* n)
{
g_atomic_int_inc (&_trigger_queue_size);
_trigger_queue.push_back (n);
@ -274,7 +274,7 @@ Graph::reached_terminal_node ()
* - Reset terminal reference count
* - queue initial nodes
*/
prep (); // XXX
prep ();
if (_graph_empty && !g_atomic_int_get (&_terminate)) {
goto again;
@ -287,7 +287,7 @@ Graph::reached_terminal_node ()
void
Graph::run_one ()
{
GraphNode* to_run = NULL;
ProcessNode* to_run = NULL;
if (g_atomic_int_get (&_terminate)) {
return;