Channel race condition and other issues
Channel::clear does not broadcast and reset counters
After popping everything from the queue,
Channel::cleardoes not broadcast for the threads waiting in
Channel::supply. It should also reset the
receivedvariables (setting received equal to sent is one solution).
Channel::demand and Channel::supply may miss a broadcast and get stuck
The mutex for the condition variable gets locked inside the loop of Channel::demand and after
pushin Channel::supply. There's a possibility a broadcast is missed if the function is outside of those locks. The mutex should be locked over loop and including push to ensure that every change to the queue is processed.
Channel wrapper uses Variant::release outside of locks
The reference counting of Variant needs to stay thread safe or LÖVE may try to execute deallocated memory or call
deleteon the same pointer twice.
Parts of the thread module do not conform to the Code Style
I see problems with the indentation, pointer and reference identifier/operator position, and initializer lists.
Edit: Fixed Channel::supply problem description and link.