love-microphone icon indicating copy to clipboard operation
love-microphone copied to clipboard

Factor out QueueableSource:step logic into QueueableSource:_freeQueues

Open LPGhatguy opened this issue 8 years ago • 2 comments

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.

LPGhatguy avatar Aug 18 '16 06:08 LPGhatguy

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.)

zorggn avatar Aug 29 '16 12:08 zorggn

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

LPGhatguy avatar Aug 29 '16 15:08 LPGhatguy