diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-04-24 21:16:01 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-04-26 09:36:07 +0000 |
| commit | c106b5d8503fe6ac1c8f45f0e4e2dcf819e3c973 (patch) | |
| tree | 4239fd2b8fa2eee769bcbd40e0b797186a759be8 /alv/copilot.moon | |
| parent | relative imports (diff) | |
| download | alive-c106b5d8503fe6ac1c8f45f0e4e2dcf819e3c973.tar.gz alive-c106b5d8503fe6ac1c8f45f0e4e2dcf819e3c973.zip | |
fix registry/module bugs
- registry not released when errors occur
- registry is no longer grabbed, problem solved ;)
- ops not reliably destroyed
- only destroy ops who were *not* forked
Diffstat (limited to 'alv/copilot.moon')
| -rw-r--r-- | alv/copilot.moon | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/alv/copilot.moon b/alv/copilot.moon index 2b97d48..7ef2134 100644 --- a/alv/copilot.moon +++ b/alv/copilot.moon @@ -20,6 +20,7 @@ class Copilot -- @tparam string file name/path of the alive file to watch and execute new: (file) => @T = 0 + @last_modification = 0 @last_modules = {} @open file if file @@ -54,8 +55,11 @@ class Copilot last = @active_module prefix = @active_module.file\match('(.*)/[^/]*$') .. '/' or '' mod = @last_modules[name] or Module "#{prefix}#{name}.alv" + L\trace "entering module #{mod}" + @modules[name] = mod @active_module = mod ok, err = pcall mod\eval + L\trace "returning to module #{mod}" @active_module = last if ok mod.root @@ -90,11 +94,12 @@ class Copilot poll: => dirty = {} for name, mod in pairs @last_modules - if mod\poll! + if mod\poll! > @last_modification table.insert dirty, mod return if #dirty == 0 + @last_modification = os.time! L\set_time 'eval' L\print "changes to files: #{table.concat [m.file for m in *dirty], ', '}" @@ -115,6 +120,7 @@ class Copilot for name, mod in pairs @modules mod\finish! + @last_modification = os.time! @last_modules, @modules = @modules, nil { |
