Documentation
¶
Overview ¶
channel-timeout shows the cancellable receive pattern: a Go callback that blocks on a channel reads L.Context() and selects on its Done() channel, so a SetContext deadline frees the goroutine instead of blocking forever. This is the recommended way to do blocking I/O in a callback — a plain <-ch would ignore the deadline (the VM only checks the context between instructions).
On timeout recv raises a clean, position-prefixed error with L.RaiseError (PUC luaL_error), which the script catches with pcall — so a stuck receive surfaces as a normal Lua error instead of hanging.
Click to show internal directories.
Click to hide internal directories.