summaryrefslogtreecommitdiff
path: root/xmake/core/base/thread.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-03 22:40:25 +0800
committerruki <[email protected]>2025-11-07 15:01:56 +0800
commit85980580cf9fab96edda2325b59fb315fed4a7ce (patch)
treec283b766e457a0b989eaf812ed1560015531c1a0 /xmake/core/base/thread.lua
parentec6e12c9f2fd8533d06e177ddc0a6dcf3e127757 (diff)
impl os.cp/rm in async task
Diffstat (limited to 'xmake/core/base/thread.lua')
-rw-r--r--xmake/core/base/thread.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/xmake/core/base/thread.lua b/xmake/core/base/thread.lua
index 3856feb81..65e161050 100644
--- a/xmake/core/base/thread.lua
+++ b/xmake/core/base/thread.lua
@@ -52,6 +52,7 @@ function _thread.new(callback, opt)
instance._CALLBACK = callback
instance._STACKSIZE = opt.stacksize or 0
instance._STATUS = thread.STATUS_READY
+ instance._INTERNAL = opt.internal
setmetatable(instance, _thread)
return instance
end
@@ -129,7 +130,7 @@ function _thread:start()
-- init callback info
local callback = string._dump(self._CALLBACK)
- local callinfo = {name = self:name(), argv = argv}
+ local callinfo = {name = self:name(), argv = argv, internal = self._INTERNAL}
-- we need a pipe pair to wait and listen thread exit event
local rpipe, wpipe = pipe.openpair("AA")
@@ -808,6 +809,7 @@ function thread._run_thread(callback_str, callinfo_str)
local argv
local threadname
local wpipe
+ local is_internal = false
if callinfo_str then
local result, errors = string.deserialize(callinfo_str)
if not result then
@@ -817,6 +819,7 @@ function thread._run_thread(callback_str, callinfo_str)
if callinfo then
argv = callinfo.argv
threadname = callinfo.name
+ is_internal = callinfo.internal
wpipe = pipe.new(libc.ptraddr(callinfo.wpipe, {ffi = false}))
end
end
@@ -850,6 +853,11 @@ function thread._run_thread(callback_str, callinfo_str)
return false, errors
end
+ -- if it's an internal thread, we need to bind some additional internal interfaces.
+ if is_internal then
+ sandbox_inst:api_register_builtin("require", require)
+ end
+
-- save the running thread name
thread._RUNNING = threadname