summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-08 00:50:54 +0800
committerruki <[email protected]>2025-11-08 00:50:54 +0800
commit418d1e6a2feae05880e7389d27ddaaa46c5e39e5 (patch)
tree75993dad62e4b0e7b826c24e909a61786d198295
parentaad9c244ead90ba767e41cc971812d469130f41f (diff)
improve pipe_event
-rw-r--r--xmake/core/base/private/pipe_event.lua10
1 files changed, 3 insertions, 7 deletions
diff --git a/xmake/core/base/private/pipe_event.lua b/xmake/core/base/private/pipe_event.lua
index 20f1373fb..8d1278766 100644
--- a/xmake/core/base/private/pipe_event.lua
+++ b/xmake/core/base/private/pipe_event.lua
@@ -33,7 +33,7 @@ function _instance.new(name)
event._PIPE_EVENT = true
event._BUFFER = bytes(2)
event._NAME = name or "pipe_event"
- local reader, writer, errors = pipe.openpair("BA")
+ local reader, writer, errors = pipe.openpair("AA")
if not reader or not writer then
if reader then reader:close() end
if writer then writer:close() end
@@ -54,7 +54,7 @@ function _instance:post()
if not writer then
return false, "pipe event writer closed"
end
- local ok, errors = writer:write("1")
+ local ok, errors = writer:write("1", {block = true})
if ok < 0 then
return false, errors or "pipe event post failed"
end
@@ -68,11 +68,7 @@ function _instance:wait(timeout)
if not self._READER then
return false, "pipe event reader closed"
end
- local events, errors = self._READER:wait(pipe.EV_READ, timeout or -1)
- if events < 0 then
- return false, errors
- end
- local read, read_errors = self._READER:read(self._BUFFER, 1)
+ local read, read_errors = self._READER:read(self._BUFFER, 1, {block = true, timeout = timeout})
if read < 0 then
return false, read_errors
end