summaryrefslogtreecommitdiff
path: root/xmake/modules/lib/detect/features.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-01-25 00:49:02 +0800
committerruki <[email protected]>2024-01-25 12:10:23 +0800
commitb456912fdc3e910f9bf570ec1a9f2287027afbc1 (patch)
tree63d833f1df915fd2924e7d9c125671799fafe37d /xmake/modules/lib/detect/features.lua
parent69205c2166c14d131e1515c4fdc8c8fcdb24a101 (diff)
improve feature
Diffstat (limited to 'xmake/modules/lib/detect/features.lua')
-rw-r--r--xmake/modules/lib/detect/features.lua15
1 files changed, 5 insertions, 10 deletions
diff --git a/xmake/modules/lib/detect/features.lua b/xmake/modules/lib/detect/features.lua
index 8b9bde45b..33be29301 100644
--- a/xmake/modules/lib/detect/features.lua
+++ b/xmake/modules/lib/detect/features.lua
@@ -57,29 +57,24 @@ function main(name, opt)
_g._RESULTS = _g._RESULTS or {}
local results = _g._RESULTS
- -- @note avoid detect the same program in the same time if running in the coroutine (e.g. ccache)
- local coroutine_running = scheduler.co_running()
- if coroutine_running then
- while _g._checking ~= nil and _g._checking == key do
- scheduler.co_yield()
- end
- end
-
-- get result from the cache first
local result = results[key]
if result ~= nil then
return result
end
+ -- @see https://github.com/xmake-io/xmake/issues/4645
+ -- @note avoid detect the same program in the same time leading to deadlock if running in the coroutine (e.g. ccache)
+ scheduler.co_lock(key)
+
-- detect.tools.xxx.features(opt)?
- _g._checking = coroutine_running and key or nil
local features = import("detect.tools." .. tool.name .. ".features", {try = true})
if features then
result = features(opt)
end
- _g._checking = nil
result = result or {}
results[key] = result
+ scheduler.co_unlock(key)
return result
end