twn_textures: lock cache when adding requests
This commit is contained in:
parent
183dfa6be5
commit
6726faf719
@ -509,13 +509,13 @@ static TextureKey textures_load(TextureCache *cache, const char *path) {
|
|||||||
|
|
||||||
/* place a dummy for future lookups to know it will be loaded */
|
/* place a dummy for future lookups to know it will be loaded */
|
||||||
/* as well as a place for worker to fill in */
|
/* as well as a place for worker to fill in */
|
||||||
|
SDL_LockMutex(textures_load_mutex);
|
||||||
shput(cache->hash, path, (Texture){0});
|
shput(cache->hash, path, (Texture){0});
|
||||||
|
|
||||||
/* append a new request, use stable indices */
|
/* append a new request, use stable indices */
|
||||||
struct TextureLoadRequest const request = {
|
struct TextureLoadRequest const request = {
|
||||||
.index = shlenu(cache->hash) - 1,
|
.index = shlenu(cache->hash) - 1,
|
||||||
};
|
};
|
||||||
SDL_LockMutex(textures_load_mutex);
|
|
||||||
arrpush(texture_load_queue, request);
|
arrpush(texture_load_queue, request);
|
||||||
SDL_UnlockMutex(textures_load_mutex);
|
SDL_UnlockMutex(textures_load_mutex);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user