Post by Admin on Jul 16, 2016 3:46:24 GMT
JuDelCo @judelco Aug 15 2015 00:13
Okay, i'm pretty happy with the code now. Is optimized and doesn't break anything, but still provides a fix for the issue ( #26 )
Simon Schmid @sschmid Aug 15 2015 00:37
Awesome, thanks! I'll take a look at it!
Maxim Zaks @mzaks Aug 15 2015 05:24
@judelco I guess most of the questions were answered by @cloudjubei.
Let's talk about multithreading than
Multi threading is currently not supported. It mainly wan't work because Pool is a shared mutable object. This works great in single threaded environment, but in multi threaded one it is the worst case scenario.
In my Swift implementation of Entitas I created a DetachedEntity struct:
github.com/mzaks/Entitas/blob/master/Entitas/Entity.swift#L183
The idea behind it, you detach entity from it's pool (by creating a copy as a struct with a reference to original entity object), change it on another thread and than sync back on the main thread. However you have to be cation about syncing because this entity might be already destroyed, or you will overwrite some fresh changes.
Another idea is having multiple pool instances per thread. If you don't share state cross threads everything is fine. If you want to start syncing data between those two pools, thats where all the fun comes from.
Btw here is the link to the talk that @cloudjubei mentioned.
www.infoq.com/presentations/multithreading
JuDelCo @judelco Aug 15 2015 07:13
I have readed all the conversation in this chat from his origin. I want to say something about the statement i readed a lot about "code generation adds nothing other than clean api"
That's wrong: Code generation provides a optimized component cache system (like entity one). Without code generation you're on your own to optimize the use of components.
Maybe it could be merged to the base code in IComponent interface? Mmm
Okay, i'm pretty happy with the code now. Is optimized and doesn't break anything, but still provides a fix for the issue ( #26 )
Simon Schmid @sschmid Aug 15 2015 00:37
Awesome, thanks! I'll take a look at it!
Maxim Zaks @mzaks Aug 15 2015 05:24
@judelco I guess most of the questions were answered by @cloudjubei.
Let's talk about multithreading than
Multi threading is currently not supported. It mainly wan't work because Pool is a shared mutable object. This works great in single threaded environment, but in multi threaded one it is the worst case scenario.
In my Swift implementation of Entitas I created a DetachedEntity struct:
github.com/mzaks/Entitas/blob/master/Entitas/Entity.swift#L183
The idea behind it, you detach entity from it's pool (by creating a copy as a struct with a reference to original entity object), change it on another thread and than sync back on the main thread. However you have to be cation about syncing because this entity might be already destroyed, or you will overwrite some fresh changes.
Another idea is having multiple pool instances per thread. If you don't share state cross threads everything is fine. If you want to start syncing data between those two pools, thats where all the fun comes from.
Btw here is the link to the talk that @cloudjubei mentioned.
www.infoq.com/presentations/multithreading
JuDelCo @judelco Aug 15 2015 07:13
I have readed all the conversation in this chat from his origin. I want to say something about the statement i readed a lot about "code generation adds nothing other than clean api"
That's wrong: Code generation provides a optimized component cache system (like entity one). Without code generation you're on your own to optimize the use of components.
Maybe it could be merged to the base code in IComponent interface? Mmm