I was kinda stuck on this one, not because of lack of solutions but because I think the ones I invented can be improved.
I have an Amiga linked list, each node being a set a arguments to actions (functions in my code) that are executed if certain conditions are met. As the code stands now they can be executed one after the other (first one lauches the second before it's own process exits), all spawed at the same time, or not spawed at all if the same action (function) is still being executed because of previous meet conditions that lauched it and it still hasn't finished.
Now the problem is one of the possible actions is to change the arguments of the others and of itself, again if certain conditions are meet. But if a previously linked list of actions to execute, with the option to wait for the previous one to finish before starting it's execution (execute one after the other) set, is still executing, changing the arguments of the list will alter the arguments of the previously still executing list.
The solutions, well having 2 lists, but then what about if not 2 but 4, 6 or more conditions (same conditions can be meet various times per second if program is set to that) that use the same list of actions are meet. I think it would be counter productive or not very memory usage friendly to have the same number of lists of arguments as of condtions that are waiting to be or being executed (because like I said, program can be set to have the same condition veryfied varous times per second and corresponding action it launches can take a bit more time to execute. This probalby would only happend very rarely if at all but I want the program not to have this bug).
Other solution would be to copy the list each time a conditions that is associated with it is lauched. This would be better but if condition is meet a lot of times in a short period it's a whole lot of lists to copy. Probably would work (even the 1st one) but I want it to be better.
Yet another one and the one I'm trying to improve right now (or better where I'm stuck...), would be to copy only the nodes wich are to be changed so that if some still executing code still hasn't finished executing all the actions on the list, the list can be started again at the same time if a conditions associated with it is meet before the previously execution of it has finished. But if I change a pointer on the list it will afect the previous execution if it still hasn't reached that part. If I put two pointers, those would only cover 2 actions and so on...
So I though about dynamically creating a list of pointers to all the action arguments on the list to be executed that if changed in time would afect a still running previous execution of the same list. If one list node needs to be changed a copy of it will be made and then the first one substituted by the changed one. The previouly dynamically created list of pointers would still point to nodes corresponding to the first organization of the list. But this still wouldn't be the optimall solution. Suppose I have 19 actions set to wait for the previous one to finish before being lauched. To take off one node or modify it and still be able to execute the list as it was before I'd have to create pointers to all nodes before immediately before the one I want to chage that are set to wait for the previous node on the list to finish, before their execution starts.
I also though about creatign a linked list of all processes spawed for a given function that are executing at the same time but this would also be big trouble.
I wouldn't mind trying it or trying to write code on the fly as I think but in this case if I want to alter somethign I'll have to alter a whole lot of code.... hence I decided to put a post here asking for advice...
You're probably thinking why I don't stop writing by now... :-D