code clean

This commit is contained in:
Li Jie
2024-09-07 10:20:02 +08:00
parent 75fe9d61a3
commit d2538d08a7
5 changed files with 20 additions and 28 deletions

View File

@@ -54,15 +54,16 @@ func (e *Executor) Run() {
e.L.Run(libuv.RUN_DEFAULT)
}
func Run[T any](future Future[T]) (ret T) {
func Run[T any](future Future[T]) T {
loop := libuv.LoopNew()
exec := &Executor{loop}
oldExec := setExec(exec)
var ret T
future(func(v T) {
ret = v
})
exec.Run()
loop.Close()
setExec(oldExec)
return
return ret
}