mirror of
https://github.com/Hopiu/micro.git
synced 2026-04-25 00:24:45 +00:00
Remove lua.Lock
Exposing locking primitives to lua plugins is tricky and may lead to deadlocks. Instead, if possible, it's better to ensure all the needed synchonization in micro itself, without leaving this burden to lua code. Since we've added micro.After() timer API and removed exposing Go timers directly to lua, now we (probably?) have no cases of lua code possibly running asynchronously without micro controlling when it is running. So now we can remove lua.Lock. This means breaking compatibility, but, until recently lua.Lock wasn't workable at all (see #2945), which suggests that it has never been really used by anyone. So it should be safe to remove it.
This commit is contained in:
parent
4ffc2206ee
commit
1d1b363fa7
3 changed files with 0 additions and 10 deletions
|
|
@ -55,7 +55,6 @@ func luaImportMicro() *lua.LTable {
|
|||
ulua.L.SetField(pkg, "Tabs", luar.New(ulua.L, func() *action.TabList {
|
||||
return action.Tabs
|
||||
}))
|
||||
ulua.L.SetField(pkg, "Lock", luar.New(ulua.L, &ulua.Lock))
|
||||
ulua.L.SetField(pkg, "After", luar.New(ulua.L, func(t time.Duration, f func()) {
|
||||
time.AfterFunc(t, func() {
|
||||
timerChan <- f
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import (
|
|||
"github.com/zyedidia/micro/v2/internal/buffer"
|
||||
"github.com/zyedidia/micro/v2/internal/clipboard"
|
||||
"github.com/zyedidia/micro/v2/internal/config"
|
||||
ulua "github.com/zyedidia/micro/v2/internal/lua"
|
||||
"github.com/zyedidia/micro/v2/internal/screen"
|
||||
"github.com/zyedidia/micro/v2/internal/shell"
|
||||
"github.com/zyedidia/micro/v2/internal/util"
|
||||
|
|
@ -418,15 +417,11 @@ func DoEvent() {
|
|||
select {
|
||||
case f := <-shell.Jobs:
|
||||
// If a new job has finished while running in the background we should execute the callback
|
||||
ulua.Lock.Lock()
|
||||
f.Function(f.Output, f.Args)
|
||||
ulua.Lock.Unlock()
|
||||
case <-config.Autosave:
|
||||
ulua.Lock.Lock()
|
||||
for _, b := range buffer.OpenBuffers {
|
||||
b.Save()
|
||||
}
|
||||
ulua.Lock.Unlock()
|
||||
case <-shell.CloseTerms:
|
||||
case event = <-screen.Events:
|
||||
case <-screen.DrawChan():
|
||||
|
|
@ -478,12 +473,10 @@ func DoEvent() {
|
|||
return
|
||||
}
|
||||
|
||||
ulua.Lock.Lock()
|
||||
_, resize := event.(*tcell.EventResize)
|
||||
if action.InfoBar.HasPrompt && !resize {
|
||||
action.InfoBar.HandleEvent(event)
|
||||
} else {
|
||||
action.Tabs.HandleEvent(event)
|
||||
}
|
||||
ulua.Lock.Unlock()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import (
|
|||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
|
|
@ -27,7 +26,6 @@ import (
|
|||
)
|
||||
|
||||
var L *lua.LState
|
||||
var Lock sync.Mutex
|
||||
|
||||
// LoadFile loads a lua file
|
||||
func LoadFile(module string, file string, data []byte) error {
|
||||
|
|
|
|||
Loading…
Reference in a new issue