mirror of
https://github.com/zyedidia/micro
synced 2024-09-29 20:54:50 +00:00
Revert "Don't expose Go timers directly to lua" (#3211)
* Revert "Don't expose Go timers directly to lua"
This reverts commit 4ffc2206ee
.
Reason for revert: some plugins happen to use raw Go timers via
time.AfterFunc(), in an unsafe way (without synchronizing their
async code with micro). Let them keep doing that for now, in an
unsafe way but at least without immediate crashes.
Fixes #3209
* Add TODO about Go timers deprecation
This commit is contained in:
parent
fc7efbdbe9
commit
838f371486
|
@ -538,6 +538,15 @@ func importTime() *lua.LTable {
|
|||
L.SetField(pkg, "Minute", luar.New(L, time.Minute))
|
||||
L.SetField(pkg, "Hour", luar.New(L, time.Hour))
|
||||
|
||||
// TODO: these raw Go timer APIs don't provide any synchronization
|
||||
// with micro. Stop exposing them to lua once plugins switch to using
|
||||
// the safer micro.After() interface instead. See issue #3209
|
||||
L.SetField(pkg, "After", luar.New(L, time.After))
|
||||
L.SetField(pkg, "AfterFunc", luar.New(L, time.AfterFunc))
|
||||
L.SetField(pkg, "NewTicker", luar.New(L, time.NewTicker))
|
||||
L.SetField(pkg, "NewTimer", luar.New(L, time.NewTimer))
|
||||
L.SetField(pkg, "Tick", luar.New(L, time.Tick))
|
||||
|
||||
return pkg
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue