• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

xjdrew/levent: lua concurrency library based on libev, similar with gevent

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

xjdrew/levent

开源软件地址(OpenSource Url):

https://github.com/xjdrew/levent

开源编程语言(OpenSource Language):

C 49.9%

开源软件介绍(OpenSource Introduction):

levent

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.

get levent

Install lua 5.3 or newer(for lua5.2 and older, see branch lua5.2).

Clone the repository.

Read test case and examples.

Post feedback and issues on the bug tracker,

build

Need cmake 2.8 or newer.

Modify cmake.config properly and then run:

cmake .
make

ways to build on windows, ref to blog

code example

levent's api is clean, to request http concurrently is as simple as below:

lua <<SCRIPT
local levent = require "levent.levent"
local http   = require "levent.http"

local urls = {
    "http://www.google.com",
    "http://yahoo.com",
    "http://example.com",
    "http://qq.com",
}

function request(url)
    local response, err = http.get(url)
    if not response then
        print(url, "error:", err)
    else
        print(url, response:get_code())
    end
end

function main()
    for _, url in ipairs(urls) do
        levent.spawn(request, url)
    end
end

levent.start(main)
SCRIPT

running tests

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

documents

coming soon~~

licence

The MIT License (MIT) Copyright (c) 2014 xjdrew




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
AndrewFarley/Taranis-XLite-Q7-Lua-Dashboard: A simple lua-based dashboard for th ...发布时间:2022-08-16
下一篇:
lqt5/lqt: Lua Binding for Qt5发布时间:2022-08-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap