love-microphone
love-microphone copied to clipboard
Factor out QueueableSource:step logic into QueueableSource:_freeQueues
z0rg on the LOVE IRC brought up an interesting point of confusion:
QueueableSource:queue()
calls self:step()
as its first statement. This raised a question: if I'm queueing new data each frame, why should I call step
myself if queue
will call it for me?
To promote this idea, the current body of step
should be moved to a method called _freeQueues
(private-ish?), and step
should be replaced with a call to that function. Then, queue
's call to step
can be replaced with a call to this new method.
After I found that the source of that discussion was an error on the part of the user (me), i still don't get what could you separate out from step
if it only frees up queues. (I'm that z0rg by the way.)
The entire step
function becomes _freeQueues
. step
turns into:
function QueueableSource:step()
self:_freeQueues()
end
All it does is clarify where queues are going to be freed and stop the user from improperly calling step
.
Then, queue
becomes something like this:
function QueueableSource:queue()
self:_freeQueues()
-- ...
end