05-28-2024, 04:03 PM
@DSMan195276
Thank you for you suggestions.
Thank you for you suggestions.
Quote:1. Don't pass `tdata` on the stack to the thread. You should useĀ something like `malloc()` to allocate it because you don't know when the other thread will actually start using it, it could happen after invokeWorker returns.I would appreciate it if you go into more detail on this. Perhaps some sample code?
Quote:2. Your mutexes aren't doing anything because each thread has its own. You should also initialize them before starting the thread.I thought this was the case, so commented them out and had same results.
Quote:3. Because there's no lock protecting access to the images, the main thread could end up reading from the image while a worker thread has only written half a color.This was by design. Early prototypes had corruption of data across the color bands i.e. Threads were writing to the wrong color band.
Quote:4. I wouldn't declare the`dly` integer inside the SUB.These are me testing the boundaries. Clearly, in production code, I would go different route, like writing it in a different language.
5. Calling `resetWorker` from the worker thread is not safe.
2D physics engine https://github.com/mechatronic3000/fzxNGN
Untitled Rouge-like https://github.com/mechatronic3000/Untitled-Rougelike
QB Pool https://github.com/mechatronic3000/QBPool
Untitled Rouge-like https://github.com/mechatronic3000/Untitled-Rougelike
QB Pool https://github.com/mechatronic3000/QBPool