Lua sockets - Asynchronous Events

前端 未结 4 623
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-16 19:46

In current lua sockets implementation, I see that we have to install a timer that calls back periodically so that we check in a non blocking API to see if we have received a

4条回答
  •  不思量自难忘°
    2020-12-16 20:43

    Lua is inherently single-threaded; there is no such thing as an "event". There is no way to interrupt executing Lua code. So while you could rig something up that looked like an event, you'd only ever get one if you called a function that polled which events were available.

    Generally, if you're trying to use Lua for this kind of low-level work, you're using the wrong tool. You should be using C or something to access this sort of data, then pass it along to Lua when it's ready.

提交回复
热议问题