Coder Social home page Coder Social logo

Optimize for cqueues:loop(0) about cqueues HOT 4 CLOSED

wahern avatar wahern commented on July 16, 2024
Optimize for cqueues:loop(0)

from cqueues.

Comments (4)

daurnimator avatar daurnimator commented on July 16, 2024

Simple patch:

diff --git a/src/cqueues.lua b/src/cqueues.lua
index 9726e99..7a93cdf 100644
--- a/src/cqueues.lua
+++ b/src/cqueues.lua
@@ -92,7 +92,7 @@ local loader = function(loader, ...)
        core.interpose("loop", function (self, timeout)
                local ok, why

-               if timeout then
+               if timeout and timeout ~= 0 then
                        local curtime = monotime()
                        local deadline = curtime + timeout

@@ -102,7 +102,7 @@ local loader = function(loader, ...)
                        until not ok or deadline <= curtime or self:empty()
                else
                        repeat
-                               ok, why = self:step()
+                               ok, why = self:step(timeout) -- timeout is nil or 0
                        until not ok or self:empty()
                end

from cqueues.

wahern avatar wahern commented on July 16, 2024

Lastest commit refactors things so a 0 timeout doesn't result in a call to monotime.

from cqueues.

wahern avatar wahern commented on July 16, 2024

Commit is 35ce522.

from cqueues.

daurnimator avatar daurnimator commented on July 16, 2024

Great!

from cqueues.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.