1
0
Fork
You've already forked pollux
0
asynchronous i/o library for Lua
  • Zig 100%
2026年05月06日 03:16:09 +02:00
src refactor: remove dependency on moon_base 2026年05月05日 21:14:21 -04:00
.gitignore feat: initial toy implementation 2026年02月14日 19:10:13 -05:00
build.zig refactor: remove dependency on moon_base 2026年05月05日 21:14:21 -04:00
build.zig.zon refactor: remove dependency on moon_base 2026年05月05日 21:14:21 -04:00
LICENSE Initial commit 2026年02月14日 19:07:56 -05:00
README.md readme: fix lua typo 2026年05月06日 03:16:09 +02:00

Pollux

Pollux is an asynchronous i/o loop for Lua inspired by Trio and powered by Zig. Pollux is very much a work in progress.

To build Pollux, run zig build in the repository root. You can pass -Dlang=lua54 to build with Lua 5.4, for instance. A shared library object (called pollux.so on POSIX systems) will be placed in zig-out/lib. Running lua from a directory containing this library will allow the Lua interpreter to load it.

Here is some example code.

pollux = require "pollux"
pollux.run(function(px) -- px is a handle to the event loop; 
 -- note that it is only available from inside pollux.run()
 local f = px:async(function() px:sleep(4) return 5 end) -- sleeps for 4 seconds
 print("hi!") -- runs right away
 local n = f:await() -- f is a "Future" and must be awaited to get the inner value
 print("got " .. n) -- runs after 4 seconds
 -- after the second print, pollux.run() will return control to the user
end)