Basically the graveyard structure adds and removes "net" structure pointers from a list, returning them to the caller. However, if this function is called twice in any "instant" point in time (ie. between when another function is called and ends) it will break, so how do I make processes wait until the function is not being called? I was thinking of creating an "in_use" bool variable that I would use to indicate that something is currently happening:
- Code: Select all
net * graveyard::retrieve_net() {
while (in_use); // wait
in_use = true;
// do something, modify arrays, etc.
in_use = false;
return net_instance;
}
This seems a bit dodgy though, so I was wondering if there was some standard way of achieving this?
