stuarthayhurst / ammonite-engine

A simple OpenGL based graphics engine for experiments
MIT License
3 stars 1 forks source link

Use a lock-free, thread-safe work queue #13

Open stuarthayhurst opened 5 months ago

stuarthayhurst commented 5 months ago

Currently, the engine uses atomic operations for pushes to the work queue, but not for pops. Experiment with a lock-free queue for potentially better performance.

stuarthayhurst commented 1 month ago

A single producer, multi consumer queue seems like a decent compromise, since work is realistically only ever going to be submitted from 1 thread, and multiple submits can be batched to avoid taking out the lock multiple times.

Something like https://github.com/MengRao/SPMC_Queue/blob/master/SPMCQueue.h might work