Comments (4)
We could definitely make the pending-deletion list a thread-local thing, which will free everything if that thread pumps the event queue, or the thread terminates, but we chose the event queue because a) we already had something in place for dynamic event memory and b) every app (should) reliably call this function at a regular interval so the app wouldn't have to do anything new. But there's no reason we can't offer a way for a long-running thread that doesn't pump the event queue to clean the list out from time to time.
That's actually not a bad idea. That guarantees that the memory is thread-safe, and we can expose SDL_FlushEventMemory(0)
as SDL_TrimThreadMemory()
or SDL_GiveMyMemoryBackYouPeskyStringRule()
or something. :)
from sdl.
This was the original reason we weren't going to go with this approach for SDL strings. I know we had some different ideas that all had drawbacks. @icculus, what was the final solution we landed on?
from sdl.
Hmm, the current documentation says the pointer is safe until the event queue runs from any thread, but yeah, that would be a surprising result for most people.
SDL_FreeLater() holds the event lock, so you can't lose a pointer to a race condition if the main thread is in the middle of running the event queue when it happens. Anything after that just makes the race after different, if the main thread is just calling the event queue in a tight loop: do we require the memory to live at least X milliseconds, or event pumps, before it's eligible? If the background thread gets hung up for a bit, still trouble,
Let me think on this a bit.
from sdl.
We could definitely make the pending-deletion list a thread-local thing, which will free everything if that thread pumps the event queue, or the thread terminates, but we chose the event queue because a) we already had something in place for dynamic event memory and b) every app (should) reliably call this function at a regular interval so the app wouldn't have to do anything new. But there's no reason we can't offer a way for a long-running thread that doesn't pump the event queue to clean the list out from time to time.
from sdl.
Related Issues (20)
- SDL renderer "ERROR: Could not get a framebuffer" when running a SDL-release-2.30.5 program on a Debian system without X. HOT 4
- Rename some Get/Set functions to match the new naming style HOT 5
- Incorrect usage of GetStringUTFChars/NewStringUTF in android jni code HOT 1
- SDL_Renderer vulkan backend fails while re-entering the app on android HOT 7
- Gamepad not recognized by SDL but via Linux and gtk HOT 2
- [Suggestion] Make SDL_GetWindowOpacity() return the opacity value, instead of using an out parameter. HOT 2
- Is SDL_GetWinRTFSPath() still needed? HOT 1
- ios wrong documents path
- Emscripten input callbacks HOT 1
- Locale change causes Android app to restart, despite configChanges settings
- Get function conventions? HOT 5
- SDL_EVENT_WINDOW_LAST is defined as SDL_EVENT_WINDOW_PEN_LEAVE instead of SDL_EVENT_WINDOW_HDR_STATE_CHANGED HOT 2
- SDL_GetStringRule for SDL_GetJoysticks(), etc.? HOT 19
- Build failed for arm64ec target architecture HOT 4
- SDL3 SDL_Init crash on ios 15 HOT 3
- `SDL_PrintString` ignores `SDL_FormatInfo.left_justify`
- [audio][multichannel] SDL_AudioSpecsEqual failed assertion in SDL_PlaybackAudioThreadIterate due to missing stream channel map HOT 3
- Android Vukan renderer doesn't respect Landscape HOT 3
- Could you provide SDL_URIToLocal to SDL 3 in Windows too, please HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdl.