You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know if this type of API was ever been considered, but I'd like to see this form of async call API:
localnio=require("nio")
localfunctionfunc_with_cb(arg1, arg2, cb)
-- ....end-- currently, to call one function asynchronously, we have to firstly `nio.wrap` it:localasync_func=nio.wrap(func_with_cb, 2)
localret=async_func(arg1, arg2)
-- while how about we have this form of one-shot call API:localret=nio.call(func_with_cb, arg1, arg2)
-- In this form, not only we do not need to wrap it first, but also there is-- no assumption on the argc of function, and we do not need to count-- argc manually-- The API could be defined as simple as follows:functionnio.call(func, ...)
localargc=select("#", ...) +1localargs= { ... }
localret= { coroutine.yield(argc, func, ...) }
returnunpack(ret, 2, table.maxn(ret))
end
Also I wonder if it is possible to make argc optional in nio.wrap by using debug.getinfo(func, "u").nparams.
I don't know if this type of API was ever been considered, but I'd like to see this form of async call API:
Also I wonder if it is possible to make
argc
optional innio.wrap
by usingdebug.getinfo(func, "u").nparams
.EDIT: My attempt to implement these: yioneko@f057066
The text was updated successfully, but these errors were encountered: