Skip to content

Commit

Permalink
fix(*): rename function to in_yieldable_phase
Browse files Browse the repository at this point in the history
  • Loading branch information
windmgc committed Sep 25, 2023
1 parent c7396af commit a29b228
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions kong/concurrency.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local resty_lock = require "resty.lock"
local ngx_semaphore = require "ngx.semaphore"
local check_phase_yieldable = require("kong.tools.utils").check_phase_yieldable
local in_yieldable_phase = require("kong.tools.utils").in_yieldable_phase


local type = type
Expand Down Expand Up @@ -89,7 +89,7 @@ function concurrency.with_coroutine_mutex(opts, fn)
error("invalid value for opts.on_timeout", 2)
end

if not check_phase_yieldable() then
if not in_yieldable_phase() then
return fn()
end

Expand Down
8 changes: 4 additions & 4 deletions kong/tools/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,7 @@ end
-- @tparam string phase the phase to check, if not specified then
-- the default value will be the current phase
-- @treturn boolean true if the phase is yieldable, false otherwise
local check_phase_yieldable do
local in_yieldable_phase do
local get_phase = ngx.get_phase

-- https://github.com/openresty/lua-nginx-module/blob/c89469e920713d17d703a5f3736c9335edac22bf/src/ngx_http_lua_util.h#L35C10-L35C10
Expand All @@ -1669,15 +1669,15 @@ local check_phase_yieldable do
preread = true,
}

check_phase_yieldable = function(phase)
in_yieldable_phase = function(phase)
if LUA_CONTEXT_YIELDABLE_PHASE[phase or get_phase()] == nil then
return false
end
return true
end
end

_M.check_phase_yieldable = check_phase_yieldable
_M.in_yieldable_phase = in_yieldable_phase

do
local ngx_sleep = _G.native_ngx_sleep or ngx.sleep
Expand All @@ -1686,7 +1686,7 @@ do
local counter = YIELD_ITERATIONS

function _M.yield(in_loop, phase)
if ngx.IS_CLI or not check_phase_yieldable(phase) then
if ngx.IS_CLI or not in_yieldable_phase(phase) then
return
end
if in_loop then
Expand Down

0 comments on commit a29b228

Please sign in to comment.