Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Edge deletion responsibility ?

nyue
Novice
699 Views

Using the following as an illustration.

 

I can make_edge and remove_edge

 

If I delete one of the connected nodes, what happen to the edge ? does the underlying API also remove the edge or do we have to track them and remove them ourselves ?

 

What happen to message when the destination node no longer exists ?

#include <iostream>
#include <tbb/tbb.h>

void fig_3_3() {
	// step 1: construct the graph
	tbb::flow::graph g;

	// step 2:
	tbb::flow::function_node<int,std::string> my_first_node(g,
			tbb::flow::unlimited,
			[](const int &in) -> std::string {
		std::cout << "first node received: " << in << std::endl;
		return std::to_string(in);
	}
	);

	tbb::flow::function_node<std::string> my_second_node(g,
			tbb::flow::unlimited,
			[](const std::string &in) {
		std::cout << "second node received: " << in << std::endl;
	}
	);

	// step 3: add edges
	tbb::flow::make_edge(my_first_node, my_second_node);

	// step 4: send messages
	my_first_node.try_put(10);

	// step 5: wait for graph to complete
	g.wait_for_all();
}

int main() {
	fig_3_3();
	return 0;
}
0 Kudos
3 Replies
SeshaP_Intel
Moderator
682 Views

Hi,


Thank you for posting in Intel Communities.


After calling remove_edge function, the message will no longer be passed to the successor node.

You can still use the node by calling make_edge function which can build an edge between any two nodes.

Destroying the nodes while there are messages being processed in the graph can lead to premature deletion of memory which leads to program failure. Removal of nodes when the graph is not idle may lead to intermittent failures and it will be hard to find failures, so it should be avoided.


Thanks and Regards,

Pendyala Sesha Srinivas


0 Kudos
SeshaP_Intel
Moderator
649 Views

Hi,


Has the information provided above helped? If yes, could you please confirm whether we can close this thread from our end?


Thanks and Regards,

Pendyala Sesha Srinivas


0 Kudos
SeshaP_Intel
Moderator
618 Views

Hi,


We assume that your issue is resolved. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.


Thanks and Regards,

Pendyala Sesha Srinivas


0 Kudos
Reply