K
kenneth.bull
Hi,
Can someone with knowledge of C++ and threads help me?
------------
In C with structs and external functions that acts on the structs (C style of OOP/ADT programming), it was fairly easy to do multithreaded operations on things like graphs.
E.g.,
you have a some heirachy of structs to represent the graph
you have init, modify, etc. functions that are external from the struct definition
and you have operations like DFS, BFS that are also external, so inside these functions you can define stack based storage (like for "visited" flags) that saved state required to do these operations
so it these operations can be made "reentrant" or threadsafe
so you can have more than 1 thread doing a DFS search on the same graph object, for example.
---
But now in C++, if we move these operations inside the struct/class, they become tied to every objects (e.g., graph object).
So if one thread is doing somegraph.dfs( ), how can another thread also do it?
How to make it threadsafe when we include the operations inside the structs/class?
Thanks so much! (I am just learning C++ and coming from C)
Can someone with knowledge of C++ and threads help me?
------------
In C with structs and external functions that acts on the structs (C style of OOP/ADT programming), it was fairly easy to do multithreaded operations on things like graphs.
E.g.,
you have a some heirachy of structs to represent the graph
you have init, modify, etc. functions that are external from the struct definition
and you have operations like DFS, BFS that are also external, so inside these functions you can define stack based storage (like for "visited" flags) that saved state required to do these operations
so it these operations can be made "reentrant" or threadsafe
so you can have more than 1 thread doing a DFS search on the same graph object, for example.
---
But now in C++, if we move these operations inside the struct/class, they become tied to every objects (e.g., graph object).
So if one thread is doing somegraph.dfs( ), how can another thread also do it?
How to make it threadsafe when we include the operations inside the structs/class?
Thanks so much! (I am just learning C++ and coming from C)