About The Exception in game loop

clovis said:

I think in this case the engine could do it for us. Let me explain.
The engine could hide a second "List" of nodes to remove/add and effectively do it when it can do it safely (inside the GameTaskQueueManager).
Because the way the queueManager must be used is not so elegant. It could be "under the hood".
We don't need duplicate the Nodes, just mark them to be removed in the next "safe time".
Do you think its a good solution?
You mean the engine has two List to hold those nodes?It can handle this situation?Sorry,can you explain it more clearly.

clovis, your approach could also be done on the User side, and dosen't have to be in the engine i think.


spring1201 said:

oh!~~And is it safe if I attach nodes in another thread?How can I do if I want to attach nodes in another Thread?


both attaching and removing nodes from the scene graph should only be done in the main thread. but adding nodes won't result in exception, so you could say it doesn't matter much.


But I'm really confused why it sometimes throw exception while sometimes not!

You will only get an exception if you remove nodes while the scenegraph is being traversed.
You might be lucky and catch a time where the update / render loop is finished.
spring1201 said:

You mean the engine has two List to hold those nodes?It can handle this situation?Sorry,can you explain it more clearly.

I mean to do a kind of schedule to detach nodes. You, developer "mark" the nodes to detach and the engine detach the marked ones when its safe (to not throw exception) to detach.

And Core-Dump, i mean inside engine because prevent all this "are you calling this on another Thread?". Do you think it would cause much overhead?
Core-Dump said:

clovis, your approach could also be done on the User side, and dosen't have to be in the engine i think.

spring1201 said:

oh!~~And is it safe if I attach nodes in another thread?How can I do if I want to attach nodes in another Thread?


both attaching and removing nodes from the scene graph should only be done in the main thread. but adding nodes won't result in exception, so you could say it doesn't matter much.


But I'm really confused why it sometimes throw exception while sometimes not!

You will only get an exception if you remove nodes while the scenegraph is being traversed.
You might be lucky and catch a time where the update / render loop is finished.
Oh,I understand how all this happen!One of my thread detach the nodes so that rootNode in the main thread can't draw those nodes be detached.I just change the code according to your suggest,but it still throws exception.

hmm still the same exception ?