diff options
| author | ruki <[email protected]> | 2025-04-17 00:49:27 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-08-28 11:35:53 +0800 |
| commit | 3c48e6a4e5f5832e4a549578480a3e247a04e632 (patch) | |
| tree | c760b7b58c44b04bb1ad4b1c42e8795faf23671f /xmake/core/thread/thread.lua | |
| parent | 79bf2c362c3127b3b7f9b0f3e192ecff90ee8fec (diff) | |
fix callback
Diffstat (limited to 'xmake/core/thread/thread.lua')
| -rw-r--r-- | xmake/core/thread/thread.lua | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/xmake/core/thread/thread.lua b/xmake/core/thread/thread.lua index 4137efe3e..cac5d916d 100644 --- a/xmake/core/thread/thread.lua +++ b/xmake/core/thread/thread.lua @@ -41,7 +41,7 @@ function _instance.new(callback, opt) local instance = table.inherit(_instance) instance._NAME = opt.name or "anonymous" instance._ARGV = opt.argv - instance._CALLBACK = opt.callback + instance._CALLBACK = callback instance._STACKSIZE = opt.stacksize or 0 instance._STATUS = thread.STATUS_READY setmetatable(instance, _instance) @@ -90,7 +90,12 @@ function _instance:start() end assert(not self:cdata()) - local handle, errors = thread.thread_init(self:name(), self._CALLBACK, self._ARGV, self._STACKSIZE) + -- serialize and pass callback and arguments to this thread + local callback = string.serialize(self._CALLBACK, {strip = true, indent = false}) + local argv = string.serialize(self._ARGV, {strip = true, indent = false}) + + -- init and start thread + local handle, errors = thread.thread_init(self:name(), callback, argv, self._STACKSIZE) if not handle then return nil, errors or string.format("%s: failed to create thread!", self) end |
