levent is a lua concurrency networking library inspired by gevent.
Features include:
- Fast event loop based on libev.
- Simple and clean socket library
- Cooperative dns client by pure lua
- Similar api and components with gevent but with much more simpler implementation and better performance.
levent is licensed under MIT license.
Install lua 5.2 or newer.
Clone the repository.
Post feedback and issues on the bug tracker,
need cmake 2.8 or newer.
cmake .
make
ways to build on windows, ref to blog
levent's api is clean, below is a code example for how to run a time limit work
lua <<SCRIPT
local levent = require "levent.levent"
local timeout = require "levent.timeout"
function main()
print("work 1:", timeout.run(0.2, levent.sleep, 0.1))
print("work 2:", timeout.run(0.1, levent.sleep, 0.2))
end
levent.start(main)
SCRIPT
there are some tests and examples under tests
and examples
to illustrate how to use levent, you can run tests and examples from root folder of levent as below.
lua tests/test_socket.lua
lua examples/dns_mass_resolve.lua
coming soon~~
The MIT License (MIT) Copyright (c) 2014 xjdrew