threading
Monkey Forums/Monkey Programming/threading
| ||
Hi, I'm trying to load assets in a background thread so there's not an up-front loading time. I've used the diddy threading library (https://github.com/swoolcock/diddy/tree/develop/src/threading) and when I call LoadSound (from mojo,audio) from a separate thread it crashes with "Memory Access Violation". I'm not (yet) trying to play the sound or anything, just to load it. So I'm wondering if LoadSound itself is not thread-safe. Any ideas? Thanks! edit: not sure if it makes any difference but this is on windows/desktop, i'm targeting ios too but i generally test on desktop first |
| ||
Have you ever tried the built in functions from monkey? http://www.monkey-x.com/docs/html/Modules_mojo.asyncloaders.html#LoadSoundAsync i think, the default functions are not thread safe |
| ||
Oh wow, exactly what I need. Thank you! |
| ||
I don't want to steal the topic, but are there async loaders for Mojo2, or is there a way to do it using the LoadImageData function in the opengles module? I guess the trouble with just calling the loaders on another thread is that what you need to do is perform the file i/o on another thread but send the texture to gpu on whatever else needs to happen on main thread? In any case, with mojo2 I always end up writing code to queue the requests and load resources once per frame or whatever I can manage without heavily hitting the framerate. It would be so much cleaner to do it asynchronously. |