
L = require('coevent')L(function() -- 异步IO支持的环境 -- 也是业务代码local db = require('mysql')local ret,err = db:connect(...)local ret,err = db:send_query('SELECT * FROM table')local res,err = db:read_result()print(cjson.encode(res)) end)
L = require('coevent')L(function()local t1 = newthread(function()-- io codesreturn true or falseend)local t2 = newthread(function()-- io codesreturn true or falseend)local rt1 = wait(t1)local rt2 = wait(t2)end)